lang F1 2.5: contextual typing for multi-param closure literals
An untyped lambda (a, b, c) => ... now takes each param's type positionally from the expected Closure(T0, T1, T2) -> R signature, for heterogeneous param types, in both assignment and argument position. Previously only the first param (or all-same-typed params) resolved: lowerLambda's signature loop applied contextual typing into params, but the return-type-inference temp scope and the body param binding both re-resolved each param via resolveParamType -- which defaults an untyped (inferred_type) param to s64. So b in Closure(s64, string) bound as s64 and b.len errored. Both sites now read the already-resolved signature types params.items[user_param_base + i].ty (user_param_base skips the pre-populated ctx/env slots). Regression: examples/201-closure-contextual-params.sx. Note: a generic return $R inferred through a closure-typed parameter is still unresolved (folds into Phase 4 function monomorphization); concrete returns work.
This commit is contained in:
1
tests/expected/201-closure-contextual-params.exit
Normal file
1
tests/expected/201-closure-contextual-params.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
3
tests/expected/201-closure-contextual-params.txt
Normal file
3
tests/expected/201-closure-contextual-params.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
cb=15
|
||||
r=15
|
||||
q=6
|
||||
Reference in New Issue
Block a user