Files
ww/test/lang/fieldfn_leaf_collide_test.ww
Hojun-Cho 132ea4ee60 test: migrate Fam13 misc checker/coercion value tests to @test (#5-C6)
Final fold-2 chunk. The 12 Fam13 single-file value drivers move from
test/wcc/*_run.c into in-language @test row-tables under test/lang/:

- value rows -> test/lang/*_test.ww (12 files)
- reject rows -> runww //ww:error carriers (13, dual-stage non-vacuous)
- nullable abort rows -> runww //ww:run-exit 1 carriers (3)
- 953_globalslice_arg -> _runonly (cs!=ww checker divergence, #28)
- 788 value_not_type_neg + 953_arrlit_slice reject_assign kept as slim
  rc-only .c pins (divergent-diag dual-reject, mutation-gated); 788 #29

Coverage parity verified row-by-row vs each retired driver; advisor-
ratified carve taxonomy; two-round reviewed. Floor ratchet follows.
2026-06-24 22:59:32 +09:00

39 lines
1.2 KiB
Plaintext

// fieldfn_leaf_collide_test — #211: a value-receiver fn-pointer FIELD call whose
// leaf name `pull` collides with a same-module GLOBAL fn `pull` of a different
// register shape (field returns tagged (i64|sentinel), global returns scalar
// i64). Migrated from test/wcc/782_fieldfn_leaf_collide_run.c (cs==ww byte-id
// rides T2).
//
// Pre-fix wwstage cgen re-derived the call-result shape by NAME and mis-bound
// the scalar global, widening a 1-word AX into the tagged slot — silent cs!=ww.
// The fix reads the checker-stamped src.type_ off the N_CALL node. The global
// stays live (g = pull(3) = 14) so the collision is real, not dead-code-elided;
// `r is i64` / `r as i64` prove the result carries the tagged field type.
package fieldfn_leaf_collide_test;
type sentinel = void;
fn pull(x: i64) i64 = {
return x + 11i64;
};
type src = struct {
pull: fn(s: *src, k: i64) (i64 | sentinel),
};
fn srcpull(s: *src, k: i64) (i64 | sentinel) = {
return k + 100i64;
};
@test fn field_vs_global_leaf() void = {
let s: src;
s.pull = srcpull;
let g: i64 = pull(3i64);
let r = s.pull(&s, 5i64);
let out: i64 = -1i64;
if (r is i64) { out = r as i64; };
assert(out == 105i64);
assert(g == 14i64);
};