Introduce unannotated function arguments to the env as appropriate

This commit is contained in:
Ayaz Hafiz 2023-04-20 16:16:40 -05:00
parent 70adb39483
commit dc9c5b13db
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 48 additions and 10 deletions

View file

@ -3022,6 +3022,29 @@ fn constrain_typed_function_arguments(
}
}
}
// There may be argument idents left over that don't line up with the function arity.
// Add their patterns' symbols in so that they are present in the env, even though this will
// wind up a type error.
if arguments.len() > arg_types.len() {
for (pattern_var, _annotated_mark, loc_pattern) in &arguments[arg_types.len()..] {
let pattern_var_index = constraints.push_variable(*pattern_var);
def_pattern_state.vars.push(*pattern_var);
let pattern_expected =
constraints.push_pat_expected_type(PExpected::NoExpectation(pattern_var_index));
constrain_pattern(
types,
constraints,
env,
&loc_pattern.value,
loc_pattern.region,
pattern_expected,
argument_pattern_state,
);
}
}
}
fn constrain_typed_function_arguments_simple(
@ -3144,6 +3167,29 @@ fn constrain_typed_function_arguments_simple(
}
}
}
// There may be argument idents left over that don't line up with the function arity.
// Add their patterns' symbols in so that they are present in the env, even though this will
// wind up a type error.
if arguments.len() > arg_types.len() {
for (pattern_var, _annotated_mark, loc_pattern) in &arguments[arg_types.len()..] {
let pattern_var_index = constraints.push_variable(*pattern_var);
def_pattern_state.vars.push(*pattern_var);
let pattern_expected =
constraints.push_pat_expected_type(PExpected::NoExpectation(pattern_var_index));
constrain_pattern(
types,
constraints,
env,
&loc_pattern.value,
loc_pattern.region,
pattern_expected,
argument_pattern_state,
);
}
}
}
#[inline(always)]