wcc,lib/ww/syntax: resolve qualified struct-literal pkg.Type{...} (#76)

The parser folded a qualified type pkg.Type into two different node shapes by position: declaration position collapsed it into one N_TNAME (resolved via the strrchr-leaf path), but literal position left an N_DOT chain that the struct-literal typeref handoff had no resolver arm for, so pkg.Type{...} rejected with "expected type expression".

Normalize the literal-position N_DOT chain into the same source-order N_TNAME the declaration path emits, reusing the existing resolver; no new checker arm. cstage flattens at parseprimary struct-lit handoff; wwstage (no token peek) folds dots in parsepostfix and normalizes there, guarding numeric tuple components and staying in the postfix loop so trailing ops still chain. Both stages emit identical N_STRUCTLIT(N_TNAME). Prereq for qualifying wcc syntax refs (#75).
This commit is contained in:
2026-06-16 22:20:42 +09:00
parent 697e413113
commit 01b657a7ff
6 changed files with 656 additions and 1 deletions

View File

@@ -497,6 +497,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_xmod_qualstructlit_run \
$(BIN)/test_spread_variant_match \
$(BIN)/test_xmod_ident_prefer \
$(BIN)/test_xmod_valglobal_run \
@@ -1842,6 +1843,19 @@ $(BIN)/test_xmod_variant_match: test/wcc/787_xmod_variant_match.c \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# #76: a qualified struct literal `pkg.Type{...}` (type named through an
# imported module). Pre-fix it failed to parse (the dotted typeref folded
# to an N_DOT chain the checker's resolve_type had no arm for); the fix
# flattens the chain to one N_TNAME at the struct-lit handoff in BOTH
# stages. cstage driver build + run pins parse + runtime field values;
# raw w6c vs w6c_ww on the combined.ww is the rule-10 byte-id gate.
# Builds its own 2-module fixtures in a private mktemp dir.
$(BIN)/test_xmod_qualstructlit_run: test/wcc/848_xmod_qualstructlit_run.c \
$(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/w6c_ww $(BIN)/wwdump $(BIN)/wwdump_ww \
$(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