A generic free fn whose `$R` is inferred from a worker `Closure(..$args) -> $R` (+ trailing `..$args`) and which returns a type built from `$R` (`-> Wrap($R)`) monomorphizes correctly when called directly (`f(recv, worker, ..)`) but leaves `$R` UNRESOLVED when called via UFCS dot syntax (`recv.f(worker, ..)`) — the unresolved type reaches LLVM emission and trips the `.unresolved` tripwire (SIGTRAP). Distinct from RESOLVED issue 0119 (UFCS `$T` from receiver/slice). Blocks the B1.2 user-facing async idiom `context.io.async((a,b) -> R => ..., x, y)` (a UFCS call inferring $R from the worker closure's return type). The Io/async library + compiler plumbing are in place and correct (landed in the prior commit); only the UFCS call form hits this inference gap. Repro depends on no project symbols beyond modules/std.sx; unpinned (no expected/ marker) so it does not run in the corpus.
24 lines
783 B
Plaintext
24 lines
783 B
Plaintext
// Repro for issue 0151 — UFCS dot-call where `$R` is inferred from a
|
|
// worker closure's RETURN type through a variadic `..$args` pack leaves
|
|
// `$R` unresolved (SIGTRAP at LLVM emission). The DIRECT spelling
|
|
// `mymk(bx, worker, 40, 2)` resolves `$R = i64` and works; the UFCS
|
|
// spelling `bx.mymk(worker, 40, 2)` does not. Depends on no project
|
|
// symbols beyond modules/std.sx.
|
|
#import "modules/std.sx";
|
|
|
|
Box :: struct { n: i64; }
|
|
Wrap :: struct ($R: Type) { value: R; }
|
|
|
|
mymk :: ufcs (b: Box, worker: Closure(..$args) -> $R, ..$args) -> Wrap($R) {
|
|
f : Wrap($R) = ---;
|
|
f.value = worker(..args);
|
|
return f;
|
|
}
|
|
|
|
main :: () -> i32 {
|
|
bx : Box = .{ n = 1 };
|
|
g := bx.mymk((a: i64, b: i64) -> i64 => a + b, 40, 2);
|
|
print("value={}\n", g.value);
|
|
return 0;
|
|
}
|