@@ -337,75 +337,7 @@ pub fn check_file(
337337) -> BodyCheck {
338338 let file = & declarations. files [ file_index] ;
339339
340- let mut checker = Checker {
341- resolver : Resolver {
342- declarations,
343- external,
344- file : file. file ,
345- out : Signatures :: default ( ) ,
346- } ,
347- signatures,
348- scopes : Vec :: new ( ) ,
349- type_stack : Vec :: new ( ) ,
350- locals : Vec :: new ( ) ,
351- this_type : None ,
352- static_context : true ,
353- return_type : Type :: Void ,
354- lambda_probe_returns : None ,
355- lambda_stack : Vec :: new ( ) ,
356- current_member : None ,
357- captures : HashMap :: default ( ) ,
358- captured_locals : HashMap :: default ( ) ,
359- capture_types : HashMap :: default ( ) ,
360- local_functions : HashMap :: default ( ) ,
361- local_calls : HashMap :: default ( ) ,
362- declared_names : HashMap :: default ( ) ,
363- static_local_functions : HashSet :: default ( ) ,
364- local_order : 0 ,
365- local_function_order : HashMap :: default ( ) ,
366- expression_types : HashMap :: default ( ) ,
367- numeric_promotions : HashMap :: default ( ) ,
368- attribute_types : HashMap :: default ( ) ,
369- targets : HashMap :: default ( ) ,
370- pattern_inputs : HashMap :: default ( ) ,
371- enumerations : HashMap :: default ( ) ,
372- disposals : HashMap :: default ( ) ,
373- constructor_chains : HashMap :: default ( ) ,
374- catch_depth : 0 ,
375- in_async : false ,
376- awaits : HashMap :: default ( ) ,
377- iterator_element : None ,
378- yield_seen : false ,
379- value_return_seen : false ,
380- guarded_depth : 0 ,
381- catch_depth_for_yield : 0 ,
382- finally_depth : 0 ,
383- iterators : HashSet :: default ( ) ,
384- } ;
385-
386- // rebuild the same file scope signature resolution used
387- checker. scopes . push ( NamespaceScope {
388- path : Vec :: new ( ) ,
389- symbol : Some ( declarations. table . root ( ) ) ,
390- usings : Vec :: new ( ) ,
391- } ) ;
392- let mut root_usings = Vec :: new ( ) ;
393- for ( _, using) in declarations. global_usings ( ) {
394- if let Some ( resolved) = checker. resolve_using ( using) {
395- root_usings. push ( resolved) ;
396- }
397- }
398- for using in & file. usings {
399- if using. global . is_none ( )
400- && let Some ( resolved) = checker. resolve_using ( using)
401- {
402- root_usings. push ( resolved) ;
403- }
404- }
405- // using-target resolution errors were already reported by the resolve phase;
406- // this rebuild must not duplicate them
407- checker. resolver . out . errors . clear ( ) ;
408- checker. scopes [ 0 ] . usings = root_usings;
340+ let mut checker = Checker :: for_file ( declarations, signatures, external, file_index) ;
409341
410342 checker. walk_nodes ( & file. members ) ;
411343 checker. close_captures ( ) ;
@@ -576,6 +508,8 @@ struct LocalFunctionEntry<'ast> {
576508
577509struct Checker < ' a , ' ast > {
578510 resolver : Resolver < ' a , ' ast > ,
511+ /// Bounds recursive const-field binding as well as value evaluation.
512+ constant_depth : usize ,
579513 signatures : & ' a Signatures ,
580514 scopes : Vec < NamespaceScope < ' ast > > ,
581515 type_stack : Vec < SymbolId > ,
@@ -686,3 +620,86 @@ fn type_parameter_leaves(ty: &Type) -> usize {
686620 _ => 0 ,
687621 }
688622}
623+
624+ impl < ' a , ' ast > Checker < ' a , ' ast > {
625+ fn for_file (
626+ declarations : & ' a Declarations < ' ast > ,
627+ signatures : & ' a Signatures ,
628+ external : & ' a dyn ExternalTypes ,
629+ file_index : usize ,
630+ ) -> Self {
631+ let file = & declarations. files [ file_index] ;
632+ let mut checker = Checker {
633+ resolver : Resolver {
634+ declarations,
635+ external,
636+ file : file. file ,
637+ out : Signatures :: default ( ) ,
638+ } ,
639+ signatures,
640+ constant_depth : 64 ,
641+ scopes : Vec :: new ( ) ,
642+ type_stack : Vec :: new ( ) ,
643+ locals : Vec :: new ( ) ,
644+ this_type : None ,
645+ static_context : true ,
646+ return_type : Type :: Void ,
647+ lambda_probe_returns : None ,
648+ lambda_stack : Vec :: new ( ) ,
649+ current_member : None ,
650+ captures : HashMap :: default ( ) ,
651+ captured_locals : HashMap :: default ( ) ,
652+ capture_types : HashMap :: default ( ) ,
653+ local_functions : HashMap :: default ( ) ,
654+ local_calls : HashMap :: default ( ) ,
655+ declared_names : HashMap :: default ( ) ,
656+ static_local_functions : HashSet :: default ( ) ,
657+ local_order : 0 ,
658+ local_function_order : HashMap :: default ( ) ,
659+ expression_types : HashMap :: default ( ) ,
660+ numeric_promotions : HashMap :: default ( ) ,
661+ attribute_types : HashMap :: default ( ) ,
662+ targets : HashMap :: default ( ) ,
663+ pattern_inputs : HashMap :: default ( ) ,
664+ enumerations : HashMap :: default ( ) ,
665+ disposals : HashMap :: default ( ) ,
666+ constructor_chains : HashMap :: default ( ) ,
667+ catch_depth : 0 ,
668+ in_async : false ,
669+ awaits : HashMap :: default ( ) ,
670+ iterator_element : None ,
671+ yield_seen : false ,
672+ value_return_seen : false ,
673+ guarded_depth : 0 ,
674+ catch_depth_for_yield : 0 ,
675+ finally_depth : 0 ,
676+ iterators : HashSet :: default ( ) ,
677+ } ;
678+
679+ // rebuild the same file scope signature resolution used
680+ checker. scopes . push ( NamespaceScope {
681+ path : Vec :: new ( ) ,
682+ symbol : Some ( declarations. table . root ( ) ) ,
683+ usings : Vec :: new ( ) ,
684+ } ) ;
685+ let mut root_usings = Vec :: new ( ) ;
686+ for ( _, using) in declarations. global_usings ( ) {
687+ if let Some ( resolved) = checker. resolve_using ( using) {
688+ root_usings. push ( resolved) ;
689+ }
690+ }
691+ for using in & file. usings {
692+ if using. global . is_none ( )
693+ && let Some ( resolved) = checker. resolve_using ( using)
694+ {
695+ root_usings. push ( resolved) ;
696+ }
697+ }
698+ // using-target resolution errors were already reported by the resolve phase;
699+ // this rebuild must not duplicate them
700+ checker. resolver . out . errors . clear ( ) ;
701+ checker. scopes [ 0 ] . usings = root_usings;
702+
703+ checker
704+ }
705+ }
0 commit comments