You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Array literal passed to a []T parameter segfaults: the literal is typed as the slice and lowered as its fat pointer #1229
first(xs) with let xs = [5, 6], a Vec, an empty Vec and xs[0..2] all work.
Root cause (exact lines).
src/SemaCheck.wcheck_array_literal (~12157): under an expected TY_SLICE it sets target_ty to the slice type, so the literal is typed as[]i32. The call is then type-compatible, and note_slice_coerce_call_arg (~925), which would have rejected a non-place argument with "pass a named variable here…", is never reached.
src/MirLower.w NK_ARRAY_LIT (~13991-13997): emits RK_AGGREGATE with the elements as fields into a temp of expr_type(node), which is the slice type. MIR: _2 = aggregate(fields=[const 5, const 6]); call first(copy _2). The named case emits _5 = slice(_1, 0, len); the literal case emits no slice.
Codegen passes that aggregate as the fat pointer: {ptr = 5, len = 6}.
Same cause as: memcmp([1u8, 2u8], [1u8, 3u8]) through a modeled c_import buffer parameter panics "buffer arguments must have equal length".
Expected. Either the literal works (build the [T; N] backing array in a temp that lives for the statement, then slice it; the mission-preferred answer: a literal argument is the obvious spelling), or Sema rejects it with the existing diagnostic. Never a clean compile and a crash.
Tool that stayed silent.--validate-all reports ok for an aggregate whose field count and types do not match its declared slice type. The MIR typed validator should reject aggregate into a TY_SLICE place.
Activity
Fix #1229 (array literal to []T segfault) and #1230 (call through a l…