// #103/#108/#104: an INFERRED let defaults its // untyped-int element to `int` (8B machine word), not i32. Migrated from // test/wcc/813_arrlit_infer_elem_run.c (value rows; cs==ww byte-id rides T2). // // Pre-fix cstage truncated the untyped-int default to i32 (4B): a value > 2^31 // (5000000000 → 705032704) and arrays strided at 4; wwstage SEGV'd on the // inferred array (under-sized frame). The wide rows use 5000000000 ( > 2^31) as // the truncation teeth — a small value would pass both stages by luck. The // ctrl_* rows use ANNOTATED element types ([4]i32 / [4]int): the fix must leave // those untouched, so they pin the inferred-default branch is isolated. package arrlit_infer_elem_test; type myb = bool; type arr = [4]int; type arr2 = arr; type sl = []int; type sl2 = sl; @test fn arr_wide() void = { let a = [5000000000, 2, 3, 4]; assert(a[0] == 5000000000); assert(a[3] == 4); }; @test fn scalar_wide() void = { let x = 5000000000; assert(x == 5000000000); }; @test fn arr_small() void = { let a = [10, 20, 30, 40]; assert(a[2] == 30); }; @test fn m2_while() void = { let b: myb = true; let i = 0; for (b) { i = i + 1; if (i >= 3) { b = false; }; }; assert(i == 3); }; @test fn m8_range1() void = { let a: arr = [1, 2, 3, 4]; let sum = 0; for (let x .. a) { sum = sum + x; }; assert(sum == 10); }; @test fn m8_range2() void = { let a: arr2 = [1, 2, 3, 4]; let sum = 0; for (let x .. a) { sum = sum + x; }; assert(sum == 10); }; @test fn m8_slice1() void = { let a = [10, 20, 30, 40]; let s: sl = a[1:3]; assert(s.len == 2); assert(s[0] == 20); assert(s[1] == 30); }; @test fn m8_slice2() void = { let a = [10, 20, 30, 40]; let s: sl2 = a[1:3]; assert(s.len == 2); assert(s[0] == 20); let t = s[0:1]; assert(t[0] == 20); }; @test fn ctrl_i32() void = { let a: [4]i32 = [1, 2, 3, 4]; assert(a[3] == 4); }; @test fn ctrl_int() void = { let a: [4]int = [1, 2, 3, 4]; assert(a[3] == 4); };