From 2ad901d720edfc8c6c9736c6d90cbe851588c392 Mon Sep 17 00:00:00 2001 From: jacopodl Date: Mon, 2 Oct 2023 11:47:51 +0200 Subject: [PATCH] fix(Compiler): resolve variable capture issue within a closure --- argon/lang/translation_unit.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/argon/lang/translation_unit.cpp b/argon/lang/translation_unit.cpp index 073094fe..e7e291c4 100644 --- a/argon/lang/translation_unit.cpp +++ b/argon/lang/translation_unit.cpp @@ -50,6 +50,9 @@ bool TranslationUnit::IsFreeVar(String *id) const { SymbolT *sym; for (TranslationUnit *tu = this->prev; tu != nullptr; tu = tu->prev) { + if (tu->symt->type == SymbolType::STRUCT || tu->symt->type == SymbolType::TRAIT) + continue; + if ((sym = SymbolLookup(tu->symt, id)) != nullptr) { // WARNING: sym->nested must be greater than 0, // otherwise this is a global variable.