wwstage: expand spread variants in match check + size them off flattened members (#209)
The wwstage checker walked a match's raw AST variant list and never expanded a ...inner spread variant, so it rejected fmt's match over field = (...formattable | *mods) ('not a variant of scrutinee'). cstage's resolve_type flattens the spread at type-build. Mirror that in the AST exhaustiveness walk (casevariantin + a recursive checkvariantcovered): when a variant resolves to N_TTAGGED via a spread, recurse into its members. Additive + spread-gated -- typeeqast / casevariantpairmatch (#13) / casecovers untouched, so non-spread matches and 990-997 byte-id are unaffected. Also size a spread N_TTAGGED off each flattened member (mirror cstage check.c), dropping the inner union tag word (field 40B to 32B). Closes the #209 CHECKER reject; full fmt-byte-id still awaits cgen cluster #226 (io.read nominal-remap) + #227 (spread-widen ABI), so fmt tests stay cstage-only with retargeted comments. Adds test 792; regenerates w6c/wwdump combined.ww.
This commit is contained in:
15
Makefile
15
Makefile
@@ -339,6 +339,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_type_value_shadow_run \
|
||||
$(BIN)/test_xmod_alias_struct_collide_run \
|
||||
$(BIN)/test_xmod_variant_match \
|
||||
$(BIN)/test_spread_variant_match \
|
||||
$(BIN)/test_named_ptr_alias_variant_widen \
|
||||
$(BIN)/test_single_field_struct_zeroinit \
|
||||
$(BIN)/test_structvariant_largeunion_return \
|
||||
@@ -775,6 +776,20 @@ $(BIN)/test_xmod_variant_match: test/wcc/787_xmod_variant_match.c \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
# #209: a `match` over a tagged union with a `...inner` SPREAD variant
|
||||
# (e.g. fmt's `field = (...formattable | *mods)`). The wwstage checker
|
||||
# walked the raw AST u.list and false-rejected every flattened member arm
|
||||
# ("case: not a variant" / "variant not handled"), so any fmt-importing
|
||||
# unit was wwstage-uncompilable. Fix flattens the spread in the checker's
|
||||
# match validity + exhaustiveness walk (selfhost/cmd/wcc/check.ww). The
|
||||
# w6c_ww-accepts + cs==ww byte-id on the driver combined is the
|
||||
# discriminator. Self-contained single-file probe.
|
||||
$(BIN)/test_spread_variant_match: test/wcc/792_spread_variant_match.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
|
||||
$(BIN)/w6c_ww \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
# #15: widening a bare *vtable into a NAMED-alias variant (`stream` =
|
||||
# *vtable) of `(file | stream)` must compute the right tag, not default
|
||||
# to tag 0. Both-stage byte-id + runtime, plus a degenerate-ambiguity
|
||||
|
||||
Reference in New Issue
Block a user