lower: generalise the *T-where-T-expected diagnostic to any pointer

The check only caught `for xs: (*m)` loop captures; passing a `*T`
parameter or any pointer local where `T` is expected still slipped through
to the LLVM verifier. Key the diagnostic on the lowered argument's type
instead of the capture, so a `*Move` parameter forwarded into a by-value
parameter is reported the same way. Ref-capture wording is preserved.

Add example 216 (pointer-parameter case) alongside 215 (loop capture).
This commit is contained in:
agra
2026-05-31 14:17:25 +03:00
parent 39d51fc26d
commit 14d1d9d3a8
4 changed files with 48 additions and 12 deletions

View File

@@ -0,0 +1,18 @@
// Passing a `*T` where a `T` value is expected is caught at the call site —
// not only for `for xs: (*m)` loop captures (see 215) but for any pointer,
// here a `*Move` parameter forwarded into a by-value parameter. Without the
// check this slipped through to the LLVM verifier as "Call parameter type
// does not match function signature".
#import "modules/std.sx";
Move :: struct { flag: s64; }
take :: (m: Move) -> s64 { return m.flag; }
forward :: (m: *Move) -> s64 { return take(m); }
main :: () -> s32 {
mv : Move = .{ flag = 7 };
return xx forward(@mv);
}