wcc: kind-agnostic typeeq dispatch in cgmatch non-nullable arm (#179)
cgmatch's non-nullable variant-tag synthesis gated flatvariantidx on pat.kind == N_TNAME (with N_TSLICE else-branch for #19's untyped-elem fallback). N_TPTR / N_TFN / N_TPTR(N_TFN) case-patterns fell through both, leaving r=-1 → want=0 so every variant past 0 silently collapsed to tag 0 — runtime-passes only when the value happens to sit on variant 0 (zero-coincidence miscompile). Cstage cg_tag_for_variant works on resolved Type and is kind- agnostic; harec stores `_case->type = ctype` (ref/harec check.c:2527). #66 Phase-N already flipped match dispatch to typeeq; #179 is the last site still keyed on AST kind. Memory: project_tinfo_lossy_nominal + feedback "Hare = resolved-type-only match dispatch". Route through flatvariantidxt(scrutt.type_, pat.type_) directly, guarded by istaggedtype + typeisslice(pattype) for the slice axis. No new helper — existing flatvariantidxt / flatslicevariantidx wire up unchanged. 767 probe locks the fix across 5 rows: (1) nullable *fn branched store (ken's verify gate — proves the nullable arm at line 1484 isn't perturbed); (2) *i32|*i64 storing &i64 — pre-fix wwstage emitted CMPQ $0 for *i64 arm, post-fix CMPQ $1; (3) *fn(i32)|*fn(i64) via intermediate local; (4) branched runtime variant choice defeats const-fold; (5) aliased ptr variants (typeeq through TY_NAMED). Per row: cs runtime, ww runtime, cs.s == ww.s byte-id. Sibling filed inline: widening `&fn` INLINE into a fn-ptr-only tagged union picks tag 0 in wwstage's cgwidentaggedstorebp (out-of-scope; row 3 dodges via intermediate ident store).
This commit is contained in:
7
Makefile
7
Makefile
@@ -317,6 +317,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_amp_fn_ident \
|
||||
$(BIN)/test_star_fn_deref \
|
||||
$(BIN)/test_star_fn_deref_call \
|
||||
$(BIN)/test_match_variant_dispatch \
|
||||
$(BIN)/test_use_promote_alias \
|
||||
$(BIN)/test_field_signed $(BIN)/test_frame_argcount \
|
||||
$(BIN)/test_selfhost $(BIN)/test_w6a_ww $(BIN)/test_w6l_ww \
|
||||
@@ -625,6 +626,12 @@ $(BIN)/test_star_fn_deref_call: test/wcc/766_star_fn_deref_call.c \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_match_variant_dispatch: test/wcc/767_match_variant_dispatch.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
|
||||
$(BIN)/ww_ww $(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_arrlit_str_full: test/wcc/711_arrlit_str_full.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
|
||||
$(BIN)/ww_ww $(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
|
||||
|
||||
Reference in New Issue
Block a user