Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
varname_cache copies it
  • Loading branch information
youknowone committed Jul 11, 2025
commit db374ae49789e0181c29d6cb44baaaa03ca8ca9a
9 changes: 8 additions & 1 deletion compiler/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ impl Compiler<'_> {
.map(|(var, _)| var.clone())
.collect();

// Initialize varname_cache from SymbolTable::varnames
let varname_cache: IndexSet<String> = table
.varnames
.iter()
.cloned()
.collect();

// Qualname will be set later by set_qualname
let qualname = None;

Expand All @@ -420,7 +427,7 @@ impl Compiler<'_> {
current_block: ir::BlockIdx(0),
constants: IndexSet::default(),
name_cache: IndexSet::default(),
varname_cache: IndexSet::default(),
varname_cache,
cellvar_cache,
freevar_cache,
};
Expand Down
2 changes: 2 additions & 0 deletions compiler/codegen/src/symboltable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ impl SymbolTableBuilder<'_> {
.unwrap_or(false);
let table = SymbolTable::new(name.to_owned(), typ, line_number, is_nested);
self.tables.push(table);
// Clear current_varnames for the new scope
self.current_varnames.clear();
}

/// Pop symbol table and add to sub table of parent table.
Expand Down