From 9f569d1055589f264fd8c14b027015d52b8995f3 Mon Sep 17 00:00:00 2001 From: jacopodl Date: Fri, 6 Sep 2024 12:05:00 +0200 Subject: [PATCH] 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 --- argon/lang/compiler2/compiler2.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/argon/lang/compiler2/compiler2.cpp b/argon/lang/compiler2/compiler2.cpp index a8549d68..4e66b4b1 100644 --- a/argon/lang/compiler2/compiler2.cpp +++ b/argon/lang/compiler2/compiler2.cpp @@ -63,7 +63,12 @@ String *Compiler::MakeQName(String *name) { SymbolT *Compiler::IdentifierLookupOrCreate(String *id, argon::lang::compiler2::SymbolType type) { auto *dst = this->unit_->names; - auto *sym = this->unit_->symt->SymbolLookup(id, false); + auto *symt = this->unit_->symt; + + if(symt->type == SymbolType::STRUCT || symt->type == SymbolType::TRAIT) + symt = symt->back; + + auto *sym = symt->SymbolLookup(id, false); if (sym == nullptr) { auto freevar = this->unit_->IsFreeVar(id);