// #5 alias arc B7 (finale): the cgen static-DATA emitter // ELEM-type alias chases, migrated from test/wcc/944_alias_emit_b7_run.c // (#5-C3). The residual single peel was on the ELEMENT type (u->sub), so a // 2-level-elem-alias global missed the TY_STRUCT / TY_STR kind tests and fell // off the foldable-literal path: cs emitted NO DATA (link-loud, or latent // silence when unreferenced) while ww always emitted. The fix chases the elem // type at each emitter site; cs aligns UP onto ww's already-correct emit and // the rows graduate to byte-id. `type el = el0` over a named struct is ALREADY // two NAMED layers, so the "_1lvl" spelling graduates with the 2-level rows; // only a direct alias of a primitive is a true single layer. The C driver ran // each row both stages + asserted cs==ww exit; here the cstage run is // test-lang (T1) and byte-id is test-lang-byteid (T2). The slice-of-{str, // slice,tagged} BUILDERR rows and ww-checker-reject slice cells live elsewhere. package alias_emit_b7_test; // sarr_2lvl: [2]el 2-lvl alias struct — elem alias missed TY_STRUCT. type sarr2_el0 = struct { a: i64, b: i64 }; type sarr2_el1 = sarr2_el0; type sarr2_el = sarr2_el1; let g_sarr2: [2]sarr2_el = [sarr2_el0 { a = 1, b = 2 }, sarr2_el0 { a = 3, b = 4 }]; // sarr_1lvl: [2]el, el = el0 — two NAMED layers by construction. type sarr1_el0 = struct { a: i64, b: i64 }; type sarr1_el = sarr1_el0; let g_sarr1: [2]sarr1_el = [sarr1_el0 { a = 1, b = 2 }, sarr1_el0 { a = 3, b = 4 }]; type sarrc_el0 = struct { a: i64, b: i64 }; let g_sarrc: [2]sarrc_el0 = [sarrc_el0 { a = 1, b = 2 }, sarrc_el0 { a = 3, b = 4 }]; // sarr_unref_2lvl: NEVER-REFERENCED 2-lvl-elem global — pre-B7 cs silently // lacked DATA (no reference → no link error → latent silence). The byte-id vs // ww (which always emitted) is the closure pin. type sarru_el0 = struct { a: i64, b: i64 }; type sarru_el1 = sarru_el0; type sarru_el = sarru_el1; let g_sarru: [2]sarru_el = [sarru_el0 { a = 1, b = 2 }, sarru_el0 { a = 3, b = 4 }]; // strarr_2lvl: [2]ms 2-lvl alias str — eu != TY_STR → generic path can't fold // strlits → link-loud. Also pins letpreintern's intern-order coupling. type strarr2_ms0 = str; type strarr2_ms = strarr2_ms0; let g_strarr2: [2]strarr2_ms = ["aa", "bbb"]; // strarr_1lvl_ctl: type ms = str — TRUE 1-level; worked pre-B7, byte-neutral. type strarr1_ms = str; let g_strarr1: [2]strarr1_ms = ["aa", "bbb"]; let g_strarrc: [2]str = ["aa", "bbb"]; // scalararr_2lvl: [3]my64b raw-bytes path — scalar fold never consulted eu, // worked pre-B7, byte-neutral regression net. type scalararr_my64 = i64; type scalararr_my64b = scalararr_my64; let g_scalararr: [3]scalararr_my64b = [5, 6, 7]; @test fn sarr_2lvl() void = { assert(g_sarr2[0].a + g_sarr2[0].b + g_sarr2[1].a + g_sarr2[1].b == 10); }; @test fn sarr_1lvl() void = { assert(g_sarr1[0].a + g_sarr1[0].b + g_sarr1[1].a + g_sarr1[1].b == 10); }; @test fn sarr_plain_ctl() void = { assert(g_sarrc[0].a + g_sarrc[0].b + g_sarrc[1].a + g_sarrc[1].b == 10); }; // zero-consumer latent-silence pin: the global is never read in the C source's // main, so its DATA emit is asserted only by the byte-id (T2) gate; the T1 run // merely exercises the def's presence. @test fn sarr_unref_2lvl() void = { assert(g_sarru[0].a + g_sarru[0].b + g_sarru[1].a + g_sarru[1].b == 10); }; @test fn strarr_2lvl() void = { assert(len(g_strarr2[0]) == 2); assert(len(g_strarr2[1]) == 3); }; @test fn strarr_1lvl_ctl() void = { assert(len(g_strarr1[0]) == 2); assert(len(g_strarr1[1]) == 3); }; @test fn strarr_plain_ctl() void = { assert(len(g_strarrc[0]) == 2); assert(len(g_strarrc[1]) == 3); }; @test fn scalararr_2lvl() void = { assert(g_scalararr[0] + g_scalararr[1] + g_scalararr[2] == 18); };