Files
sx/examples/215-ref-capture-value-arg-diagnostic.sx
agra 39d51fc26d lower: diagnose passing a by-ref loop capture where a value is expected
`for xs: (*m)` binds `m` to a `*T`. Passing it directly to a parameter
that wants `T` produced invalid IR that only LLVM's verifier caught, with
the opaque 'Call parameter type does not match function signature'. Detect
it at the call site and emit a clear error with a fix-it suggesting `m.*`.

Add example 215 + expected output as a regression test.
2026-05-31 13:56:45 +03:00

19 lines
543 B
Plaintext

// A by-reference loop capture (`for xs: (*m)`) binds `m` to a `*T`.
// Passing it where a `T` value is expected used to slip through to the
// LLVM verifier ("Call parameter type does not match function signature").
// The compiler now reports it at the call site with a fix-it: write `m.*`.
#import "modules/std.sx";
Move :: struct { flag: s64; }
take :: (m: Move) -> s64 { return m.flag; }
main :: () -> s32 {
moves : [2]Move = .[ Move.{ flag = 1 }, Move.{ flag = 2 } ];
for moves: (*m) {
take(m);
}
return 0;
}