From 5b7366ebef82c630b60b1aac5f5ac6af80ed4f9f Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 12 Dec 2023 09:27:38 +0100 Subject: [PATCH] Fixed symbol scoping rules --- src/ulas.c | 2 +- tests/t0.bin | Bin 157 -> 160 bytes tests/t0.s | 4 ++++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ulas.c b/src/ulas.c index 0117150..d544753 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -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++; } diff --git a/tests/t0.bin b/tests/t0.bin index 6ca8b4347d11c575ab9a0995a5234d7def44386d..94bb56ddcb4e8d68f3bcc21cb7fcf63c7dd79f66 100644 GIT binary patch delta 10 RcmbQsxPWoOT;{V2837ez1K$7u delta 6 NcmZ3$IG1t4TmT3E0&M^Q diff --git a/tests/t0.s b/tests/t0.s index 5ee5c65..d0124db 100644 --- a/tests/t0.s +++ b/tests/t0.s @@ -105,3 +105,7 @@ j1: .adv 1 l3: .db 1 ld a, l3 + +; local label forward declaration + call @fl0 +@fl0: -- 2.30.2