inferGenericReturnType resolved a generic call's return-type AST ($R, !E) in the CALL-SITE module context. For a re-exported fn the error-set name (LE / IoErr, re-exported as LE :: lib.LE) resolved through the call-site alias to a TypeId NOT tagged .error_set, so the planned result was a tuple whose last field wasn't an error set — errorChannelOf saw a plain tuple and the value- failable's ! channel was lost (try/or rejected it / built a malformed i1 PHI). monomorphizeFunction already pins the source to the fn's defining module before resolving the return type; inferGenericReturnType did not, so the planned call-result type disagreed with the instance's real signature. Fix: pin the source to fd.body.source_file around the return-type resolution (binding-build stays in the call-site context — its args are typed there). Regression test examples/1058-errors-reexport-value-failable-channel.sx (+ companion lib.sx). Suite green 732/0.
9 lines
293 B
Plaintext
9 lines
293 B
Plaintext
// Implementation module: a generic value-failable `ufcs` fn + its error set.
|
|
#import "modules/std.sx";
|
|
|
|
LE :: error { Bad }
|
|
Box :: struct ($R: Type) { v: R; }
|
|
|
|
// Returns `($R, !LE)` — a value-failable. `$R` is inferred from the arg.
|
|
get :: ufcs (b: *Box($R)) -> ($R, !LE) { return b.v; }
|