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:
13
examples/0213-generics-namespaced-call-result.sx
Normal file
13
examples/0213-generics-namespaced-call-result.sx
Normal file
@@ -0,0 +1,13 @@
|
||||
// A NAMESPACED call to a generic free function types its result from the
|
||||
// call's inferred bindings — not the unbound `T` stub (issue 0127:
|
||||
// `m.pick(3, 9)` boxed as `T{}` while the flat spelling printed `9`).
|
||||
#import "modules/std.sx";
|
||||
m :: #import "0213-generics-namespaced-call-result/m.sx";
|
||||
|
||||
main :: () {
|
||||
print("{}\n", m.pick(3, 9)); // s64 binding
|
||||
print("{}\n", m.pick(1.5, 0.25)); // f64 binding
|
||||
v := m.double(21);
|
||||
w : s64 = v + 0; // the concrete type flows onward
|
||||
print("{}\n", w);
|
||||
}
|
||||
9
examples/0213-generics-namespaced-call-result/m.sx
Normal file
9
examples/0213-generics-namespaced-call-result/m.sx
Normal file
@@ -0,0 +1,9 @@
|
||||
#import "modules/std.sx";
|
||||
|
||||
pick :: (a: $T, b: T) -> T {
|
||||
if a > b then a else b
|
||||
}
|
||||
|
||||
double :: (x: $T) -> T {
|
||||
x + x
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
9
|
||||
1.500000
|
||||
42
|
||||
Reference in New Issue
Block a user