Skip to content

Commit 9f569d1

Browse files
committed
fix: this fix resolves an issue where methods incorrectly accessed instance variables instead of global variables when both shared the same name. The erroneous behavior often led to interpreter crashes. The solution ensures proper variable scope resolution within methods
1 parent a9c3e4b commit 9f569d1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

argon/lang/compiler2/compiler2.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ String *Compiler::MakeQName(String *name) {
6363
SymbolT *Compiler::IdentifierLookupOrCreate(String *id, argon::lang::compiler2::SymbolType type) {
6464
auto *dst = this->unit_->names;
6565

66-
auto *sym = this->unit_->symt->SymbolLookup(id, false);
66+
auto *symt = this->unit_->symt;
67+
68+
if(symt->type == SymbolType::STRUCT || symt->type == SymbolType::TRAIT)
69+
symt = symt->back;
70+
71+
auto *sym = symt->SymbolLookup(id, false);
6772
if (sym == nullptr) {
6873
auto freevar = this->unit_->IsFreeVar(id);
6974

0 commit comments

Comments
 (0)