lang F1 6: contextually type pack-fn prefix args (mapper lambda)
lowerPackFnCall lowered the runtime prefix args with no target_type, so a lambda arg (mapper: Closure(...) -> ...) could not infer its param types. Now set target_type to the param type while lowering each prefix arg. With the existing value-projection call-arg spread, mapper(..sources.get) works: the lambda is contextually typed and the projected values spread into the call. examples/211 ((a,b)=>a+b over two sources -> 42). 246 + unit green.
This commit is contained in:
@@ -9195,7 +9195,13 @@ pub const Lowering = struct {
|
||||
if (isPackParam(p)) break;
|
||||
if (ri >= call_node.args.len) break;
|
||||
if (!p.is_comptime) {
|
||||
// Contextually type the arg from the param (so a lambda arg
|
||||
// `(x) => …` takes its param types from a `Closure(...)` param).
|
||||
const saved_tt = self.target_type;
|
||||
const pty = self.resolveParamType(&p);
|
||||
if (pty != .unresolved) self.target_type = pty;
|
||||
args.append(self.alloc, self.lowerExpr(call_node.args[ri])) catch return self.builder.constInt(0, .void);
|
||||
self.target_type = saved_tt;
|
||||
}
|
||||
ri += 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user