From 2323f46a542bbcdc6e422d6de959bfdad6dbebfb Mon Sep 17 00:00:00 2001 From: Daniel Serpell Date: Sat, 16 Aug 2025 17:29:12 -0400 Subject: [PATCH] Only search a symbol in parent scopes if not already scoped. This fixes the case at: https://github.com/cc65/cc65/pull/1358#issuecomment-747194906 --- src/ca65/studyexpr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ca65/studyexpr.c b/src/ca65/studyexpr.c index 11e4ca2f9..0c872a6cc 100644 --- a/src/ca65/studyexpr.c +++ b/src/ca65/studyexpr.c @@ -646,10 +646,14 @@ static void StudySymbol (ExprNode* Expr, ExprDesc* D) ** about the address size, check higher lexical levels for a symbol ** with the same name and use its address size if we find such a ** symbol which is defined. + ** + ** Only do the search if the symbol is not in the current scope, + ** assume scoped symbols can't be resolved in a different scope. */ AddrSize = GetSymAddrSize (Sym); Parent = GetSymParentScope (Sym); - if (AddrSize == ADDR_SIZE_DEFAULT && Parent != 0) { + if (AddrSize == ADDR_SIZE_DEFAULT && Parent != 0 && + Sym->Sym.Tab == CurrentScope) { SymEntry* H = SymFindAny (Parent, GetSymName (Sym)); if (H) { AddrSize = GetSymAddrSize (H);