@@ -560,31 +560,35 @@ impl<'a, A> ModuleAnalyzer<'a, A> {
560
560
has_javascript_external : external_javascript. is_some ( ) ,
561
561
} ;
562
562
563
- let mut typed_arguments = Vec :: with_capacity ( arguments. len ( ) ) ;
564
- for ( argument, type_) in arguments. into_iter ( ) . zip ( & prereg_arguments_types) {
565
- let argument = argument. set_type ( type_. clone ( ) ) ;
566
- match & argument. names {
567
- ast:: ArgNames :: Named { .. } | ast:: ArgNames :: NamedLabelled { .. } => ( ) ,
568
- ast:: ArgNames :: Discard { name, location }
569
- | ast:: ArgNames :: LabelledDiscard {
570
- name,
571
- name_location : location,
572
- ..
573
- } => {
574
- let _ = environment. discarded_names . insert ( name. clone ( ) , * location) ;
575
- }
576
- }
577
-
578
- typed_arguments. push ( argument) ;
579
- }
580
-
581
563
// We have already registered the function in the `register_value_from_function`
582
564
// method, but here we must set this as the current function again, so that anything
583
565
// we reference in the body of it can be tracked properly in the call graph.
584
566
environment. references . set_current_node ( name. clone ( ) ) ;
585
567
568
+ let mut typed_arguments = Vec :: with_capacity ( arguments. len ( ) ) ;
569
+
586
570
// Infer the type using the preregistered args + return types as a starting point
587
571
let result = environment. in_new_scope ( & mut self . problems , |environment, problems| {
572
+ for ( argument, type_) in arguments. into_iter ( ) . zip ( & prereg_arguments_types) {
573
+ let argument = argument. set_type ( type_. clone ( ) ) ;
574
+
575
+ // We track which arguments are discarded so we can provide nice
576
+ // error messages when someone
577
+ match & argument. names {
578
+ ast:: ArgNames :: Named { .. } | ast:: ArgNames :: NamedLabelled { .. } => ( ) ,
579
+ ast:: ArgNames :: Discard { name, location }
580
+ | ast:: ArgNames :: LabelledDiscard {
581
+ name,
582
+ name_location : location,
583
+ ..
584
+ } => {
585
+ let _ = environment. discarded_names . insert ( name. clone ( ) , * location) ;
586
+ }
587
+ }
588
+
589
+ typed_arguments. push ( argument) ;
590
+ }
591
+
588
592
let mut expr_typer = ExprTyper :: new ( environment, definition, problems) ;
589
593
expr_typer. hydrator = self
590
594
. hydrators
0 commit comments