Skip to content

Commit db374ae

Browse files
committed
varname_cache copies it
1 parent 1abe636 commit db374ae

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/codegen/src/compile.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,13 @@ impl Compiler<'_> {
399399
.map(|(var, _)| var.clone())
400400
.collect();
401401

402+
// Initialize varname_cache from SymbolTable::varnames
403+
let varname_cache: IndexSet<String> = table
404+
.varnames
405+
.iter()
406+
.cloned()
407+
.collect();
408+
402409
// Qualname will be set later by set_qualname
403410
let qualname = None;
404411

@@ -420,7 +427,7 @@ impl Compiler<'_> {
420427
current_block: ir::BlockIdx(0),
421428
constants: IndexSet::default(),
422429
name_cache: IndexSet::default(),
423-
varname_cache: IndexSet::default(),
430+
varname_cache,
424431
cellvar_cache,
425432
freevar_cache,
426433
};

compiler/codegen/src/symboltable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ impl SymbolTableBuilder<'_> {
626626
.unwrap_or(false);
627627
let table = SymbolTable::new(name.to_owned(), typ, line_number, is_nested);
628628
self.tables.push(table);
629+
// Clear current_varnames for the new scope
630+
self.current_varnames.clear();
629631
}
630632

631633
/// Pop symbol table and add to sub table of parent table.

0 commit comments

Comments
 (0)