wwstage: match cross-module union variants by (module, leaf) pair (#13)
wwstage's checker rejected matching an imported union's variants cross-module: casevariantin/casecovers' typeeqast did a raw streq, so a union's bare variant "unsupported" failed to match the dotted case pattern "errors.unsupported" (cstage compares resolved-Type identity, qualifier-agnostic). Add a (module, leaf)-pair fallback after typeeqast: reduce both the case pattern and each variant to (module, leaf) and match on pair equality -- a dotted name keeps its own qualifier, a bare name takes the union's defining module (taggeddefmod, via the aliassym hop chain). This closes BOTH directions: the false-reject of valid cross-module match AND a false-accept of a foreign same-leaf qualifier (case othermod.foo vs errors.error now rejected, matching cstage). Handles the nested errors.error-in-io.error case (the dotted variant keeps mod=errors, not the union's mod=io). typeeqast stays the first check so currently-valid code is byte-id-unchanged; the pair-match fires only on the previously-rejected qualified-vs-bare mix. Wired into casevariantin, casecovers, and the is/as caller. Adds test/wcc/787 (cross-module positive, exhaustiveness, foreign-qualifier reject-guard, dotted-variant body). Unblocks #5's cross-module io.error/errors.error decomposition. rule-10 fix-up; #10-family (wwstage cross-module resolution).
This commit is contained in:
12
Makefile
12
Makefile
@@ -336,6 +336,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_fieldfn_leaf_collide_run \
|
||||
$(BIN)/test_amp_fn_assign_run \
|
||||
$(BIN)/test_xmod_alias_struct_collide_run \
|
||||
$(BIN)/test_xmod_variant_match \
|
||||
$(BIN)/test_structvariant_largeunion_return \
|
||||
$(BIN)/test_narrow_alias_deref_store \
|
||||
$(BIN)/test_bufio_vstream_run \
|
||||
@@ -743,6 +744,17 @@ $(BIN)/test_xmod_alias_struct_collide_run: test/wcc/784_xmod_alias_struct_collid
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
# #13: cross-module decomposition of an imported union's variants
|
||||
# (`case pkg.a`). Pre-fix the wwstage checker rejected it; cstage built
|
||||
# it. cstage driver build + run pins routing; raw w6c_ww on the
|
||||
# combined.ww (must now accept) + cs==ww byte-id is the discriminator.
|
||||
# Builds its own 2-module fixtures in a private mktemp dir.
|
||||
$(BIN)/test_xmod_variant_match: test/wcc/787_xmod_variant_match.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
|
||||
$(BIN)/w6c_ww \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
# #9: returning a STRUCT variant of a LARGE (>4-eightbyte) tagged union.
|
||||
# Both-stage byte-id + runtime (reads tag AND the widened &fn field, so a
|
||||
# dropped-store regression can't hide behind self-consistent byte-id).
|
||||
|
||||
Reference in New Issue
Block a user