// 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); };