fix(0127): namespaced generic calls type their result from the call's bindings
The plan producer's namespace-fn arms returned the declared return type
without checking type_params, so a qualified generic call's result
carried the unbound T stub: print boxed it as 'T{}', and a non-s64
binding failed LLVM verification (pack monomorphized for the stub,
call returning double). Both fn_ast_map-backed arms now classify
generic callees as generic_fn and infer the return through
inferGenericReturnType, mirroring the bare-identifier path.
This commit is contained in:
@@ -437,6 +437,15 @@ pub const CallResolver = struct {
|
||||
};
|
||||
}
|
||||
if (self.l.program_index.fn_ast_map.get(qualified)) |qfd| {
|
||||
// Generic callee: the declared return type is the unbound
|
||||
// `T` stub — infer through the call's bindings, exactly
|
||||
// like the bare-identifier path above.
|
||||
if (qfd.type_params.len > 0) return .{
|
||||
.kind = .generic_fn,
|
||||
.return_type = self.l.genericResolver().inferGenericReturnType(qfd, c),
|
||||
.target = .{ .named = qualified },
|
||||
.expands_defaults = defaultsFor(qfd, c.args.len),
|
||||
};
|
||||
return .{
|
||||
.kind = .namespace_fn,
|
||||
.return_type = if (qfd.return_type) |rt| self.l.resolveTypeInSource(self.l.program_index.qualified_fn_source.get(qualified), rt) else .void,
|
||||
@@ -447,6 +456,12 @@ pub const CallResolver = struct {
|
||||
// Namespace aliases sometimes register the function under its
|
||||
// bare name (matches `lowerCall`'s effective-name resolution).
|
||||
if (self.l.program_index.fn_ast_map.get(cfa.field)) |bfd| {
|
||||
if (bfd.type_params.len > 0) return .{
|
||||
.kind = .generic_fn,
|
||||
.return_type = self.l.genericResolver().inferGenericReturnType(bfd, c),
|
||||
.target = .{ .named = cfa.field },
|
||||
.expands_defaults = defaultsFor(bfd, c.args.len),
|
||||
};
|
||||
return .{
|
||||
.kind = .namespace_fn,
|
||||
.return_type = if (bfd.return_type) |rt| self.l.resolveTypeInSource(self.l.program_index.qualified_fn_source.get(qualified), rt) else .void,
|
||||
|
||||
Reference in New Issue
Block a user