Constrain function type on closure type, not signature

This commit is contained in:
Ayaz Hafiz 2022-10-05 17:16:27 -05:00
parent 8310230f78
commit 54e977be2d
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58

View File

@ -1510,8 +1510,12 @@ fn constrain_function_def(
loc_symbol.value,
Loc {
region: loc_function_def.region,
// todo can we use Type::Variable(expr_var) here?
value: signature.clone(),
// NOTE: we MUST use `expr_var` here so that the correct type variable is
// associated with the function. We prefer this to the annotation type, because the
// annotation type may be instantiated into a fresh type variable that is
// disassociated fromt the rest of the program.
// Below, we'll check that the function actually matches the annotation.
value: Type::Variable(expr_var),
},
);