Skip to content

Commit acc26c0

Browse files
committed
When the scope is not found on ancestors, create on current scope.
This solves comment #1358 (comment)
1 parent 2323f46 commit acc26c0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

doc/ca65.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ if you want to access the "other" symbol <tt/bar/, you would have to write:
13201320
</verb></tscreen>
13211321

13221322
The above example also shows that to search a scope that is not yet defined in
1323-
the code above the usage, you must use the namespace token (<tt/::/) and
1323+
the code above the usage, you should use the namespace token (<tt/::/) and
13241324
specify the full scope name, to allow the assembler to create the scope at the
13251325
correct place.
13261326

src/ca65/symbol.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,14 @@ SymTable* ParseScopedIdent (StrBuf* Name, StrBuf* FullName)
9494
*/
9595
Scope = SymFindAnyScope (CurrentScope, Name);
9696
if (Scope == 0) {
97-
/* Scope not found */
98-
SB_Terminate (FullName);
99-
Error ("No such scope: `%m%p'", FullName);
100-
return 0;
97+
/* Scope not found, create a new scope here */
98+
Scope = SymFindScope (CurrentScope, Name, SYM_ALLOC_NEW);
99+
if (Scope == 0) {
100+
SB_Terminate (FullName);
101+
/* Scope not found */
102+
Error ("Can't create scope: `%m%p'", FullName);
103+
return 0;
104+
}
101105
}
102106

103107
} else {

0 commit comments

Comments
 (0)