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
This commit is contained in:
Daniel Serpell
2025-08-16 17:29:12 -04:00
parent 76e31e5b75
commit 2323f46a54

View File

@@ -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);