@@ -189,7 +189,7 @@ impl<'a> SemanticBuilder<'a> {
189189 /// # Panics
190190 pub fn build ( mut self , program : & Program < ' a > ) -> SemanticBuilderReturn < ' a > {
191191 if self . source_type . is_typescript_definition ( ) {
192- let scope_id = self . scope . add_scope ( None , ScopeFlags :: Top ) ;
192+ let scope_id = self . scope . add_scope ( None , AstNodeId :: dummy ( ) , ScopeFlags :: Top ) ;
193193 program. scope_id . set ( Some ( scope_id) ) ;
194194 } else {
195195 self . visit_program ( program) ;
@@ -449,7 +449,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
449449 flags = self . scope . get_new_scope_flags ( flags, parent_scope_id) ;
450450 }
451451
452- self . current_scope_id = self . scope . add_scope ( parent_scope_id, flags) ;
452+ self . current_scope_id = self . scope . add_scope ( parent_scope_id, self . current_node_id , flags) ;
453453 scope_id. set ( Some ( self . current_scope_id ) ) ;
454454
455455 if let Some ( parent_scope_id) = parent_scope_id {
@@ -471,8 +471,6 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
471471 if !flags. is_top ( ) {
472472 self . bind_function_or_class_expression ( ) ;
473473 }
474-
475- self . add_current_node_id_to_current_scope ( ) ;
476474 }
477475
478476 fn leave_scope ( & mut self ) {
@@ -501,6 +499,15 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
501499
502500 fn visit_program ( & mut self , program : & Program < ' a > ) {
503501 let kind = AstKind :: Program ( self . alloc ( program) ) ;
502+ /* cfg */
503+ let error_harness = control_flow ! ( |self , cfg| {
504+ let error_harness = cfg. attach_error_harness( ErrorEdgeKind :: Implicit ) ;
505+ let _program_basic_block = cfg. new_basic_block_normal( ) ;
506+ error_harness
507+ } ) ;
508+ /* cfg - must be above directives as directives are in cfg */
509+
510+ self . enter_node ( kind) ;
504511 self . enter_scope (
505512 {
506513 let mut flags = ScopeFlags :: Top ;
@@ -512,16 +519,6 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
512519 & program. scope_id ,
513520 ) ;
514521
515- /* cfg */
516- let error_harness = control_flow ! ( |self , cfg| {
517- let error_harness = cfg. attach_error_harness( ErrorEdgeKind :: Implicit ) ;
518- let _program_basic_block = cfg. new_basic_block_normal( ) ;
519- error_harness
520- } ) ;
521- /* cfg - must be above directives as directives are in cfg */
522-
523- self . enter_node ( kind) ;
524-
525522 for directive in & program. directives {
526523 self . visit_directive ( directive) ;
527524 }
@@ -1778,10 +1775,6 @@ impl<'a> SemanticBuilder<'a> {
17781775 }
17791776 }
17801777
1781- fn add_current_node_id_to_current_scope ( & mut self ) {
1782- self . scope . set_node_id ( self . current_scope_id , self . current_node_id ) ;
1783- }
1784-
17851778 fn make_all_namespaces_valuelike ( & mut self ) {
17861779 for symbol_id in & self . namespace_stack {
17871780 // Ambient modules cannot be value modules
0 commit comments