Fixed symbol scoping rules
authorLukas Krickl <lukas@krickl.dev>
Tue, 12 Dec 2023 08:27:38 +0000 (09:27 +0100)
committerLukas Krickl <lukas@krickl.dev>
Tue, 12 Dec 2023 08:27:38 +0000 (09:27 +0100)
src/ulas.c
tests/t0.bin
tests/t0.s

index 0117150fd186cfca2b8f28eea28f617ea4714c51..d544753e2902f75c6fcf39161b663bdb0d5378d4 100644 (file)
@@ -287,7 +287,7 @@ int ulas_symbolset(const char *cname, int scope, struct ulas_tok tok,
 
   struct ulas_sym *existing = ulas_symbolresolve(name, scope, &resolve_rc);
   // inc scope when symbol is global
-  if (name[0] != ULAS_TOK_SCOPED_SYMBOL_BEGIN) {
+  if (name[0] != ULAS_TOK_SCOPED_SYMBOL_BEGIN && cname[len - 1] == ':') {
     ulas.scope++;
   }
 
index 6ca8b4347d11c575ab9a0995a5234d7def44386d..94bb56ddcb4e8d68f3bcc21cb7fcf63c7dd79f66 100644 (file)
Binary files a/tests/t0.bin and b/tests/t0.bin differ
index 5ee5c656e68c2bc78bfff5b04946ccdfd0e66404..d0124dbee7c7ec59d1c37df914be0fc37453804e 100644 (file)
@@ -105,3 +105,7 @@ j1:
 .adv 1
 l3: .db 1
   ld a, l3
+
+; local label forward declaration 
+  call @fl0
+@fl0: