wcc/check: #25 reject overlong array-lit in a tuple return (wwstage)

This commit is contained in:
2026-06-09 15:01:34 +09:00
parent 89f3e58458
commit f767819b41
4 changed files with 60 additions and 0 deletions

View File

@@ -15123,6 +15123,19 @@ fn checkretassign(c: *checker, n: *node) void = {
if (n.lhs.kind == nkind.N_ARRLIT) {
checkarrlitfits(c, c.fnret, n.lhs);
};
// #25: array-typed element of a TUPLE RETURN with an overlong array
// literal — `fn f() ([2]int,i32) = { return ([1,2,3],5); }`. #20
// wired the tuple over-fill walk at the LET position only; the
// return path runs through checkretassign which never routed tuple
// elements through checkarrlitfits. Reuse the #26 helper. Fire
// BEFORE the isassignable/conf guards (a tuple return drives
// conf=false → short-circuit), same reason as the #12 array arm
// above. Alias/!-aware on the fnret tuple type.
let rrt: *node = resolvealias(c, unwrapbang(c.fnret));
if (rrt != nil && rrt.kind == nkind.N_TTUPLE
&& n.lhs.kind == nkind.N_TUPLE) {
checktuplearrfits(c, rrt, n.lhs);
};
let src: *node = exprtype(c, n.lhs, nil);
if (src == nil) { return; };
let conf: bool = false;