Skip to content

Commit

Permalink
fix(transformer): add to SymbolTable::declarations for all symbols (#…
Browse files Browse the repository at this point in the history
…4460)

`declarations` field of `SymbolTable` is part of the SoA group field. For it to be valid to index into with `SymbolId`, an entry must be added for every new symbol which is created.
  • Loading branch information
overlookmotel committed Jul 26, 2024
1 parent a49f491 commit c04b9aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/oxc_transformer/src/typescript/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use oxc_allocator::Vec;
use oxc_ast::{ast::*, visit::walk_mut, VisitMut};
use oxc_span::{Atom, Span, SPAN};
use oxc_syntax::{
node::AstNodeId,
number::{NumberBase, ToJsInt32, ToJsString},
operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator},
reference::ReferenceFlag,
Expand Down Expand Up @@ -80,6 +81,7 @@ impl<'a> TypeScriptEnum<'a> {
SymbolFlags::FunctionScopedVariable,
func_scope_id,
);
ctx.symbols_mut().add_declaration(AstNodeId::DUMMY);
let ident = BindingIdentifier {
span: decl.id.span,
name: decl.id.name.clone(),
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_traverse/src/context/scoping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl TraverseScoping {

// Add binding to scope
let symbol_id = self.symbols.create_symbol(SPAN, name.clone(), flags, scope_id);
self.symbols.add_declaration(AstNodeId::DUMMY);
self.scopes.add_binding(scope_id, name, symbol_id);
symbol_id
}
Expand Down

0 comments on commit c04b9aa

Please sign in to comment.