wcc/ww: module-scope the cgen mangle-hint (#40)

use_hint/usehint were unit-global first-leaf-match: two directory-
packages exporting the same fn leaf, each imported by a different module
aliasing the same bareword, mis-routed every qualified call to whichever
use was collected first. Identically wrong on both stages (byte-id-green
#263-class). Key the hint on (owner-module, alias) and prefer cur_mod,
mirroring the checker's use_path curmod-preference (55f54fb).

989_m1usehint_run: two same-leaf pick() across a.math/b.math, each
module's call routes to its own import (111/222) + cs.s==ww.s.
This commit is contained in:
2026-06-15 19:01:51 +09:00
parent f308818b4b
commit e9c11cb5ae
6 changed files with 364 additions and 44 deletions

View File

@@ -267,6 +267,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_chainidx_run \
$(BIN)/test_m1mangle_run \
$(BIN)/test_m1mangle_sym \
$(BIN)/test_m1usehint_run \
$(BIN)/test_m1union_run \
$(BIN)/test_tupfieldsize_run \
$(BIN)/test_tagtupfieldsize_run \
@@ -837,6 +838,18 @@ $(BIN)/test_m1mangle_sym: test/wcc/989_m1mangle_sym.c \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_m1usehint_run (M1, #40): the cgen mangle-hint must be MODULE-scoped.
# Two same-leaf exported fns across directory-packages, each `import`ed by a
# different module aliasing `math`; every `math.pick()` must route to its own
# import (not the file-global first-match). Builds+runs on BOTH stages + pins
# cstage.s==wwstage.s — the gate-VISIBLE #263-class hint miscompile.
$(BIN)/test_m1usehint_run: test/wcc/989_m1usehint_run.c \
$(BIN)/ww $(BIN)/ww_ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_m1union_run (M1, #199b): a `match` on a cross-module fn's tagged-union
# return must keep each nominal void-alias variant on a distinct tag. Builds+
# runs the utf8.next 4-arm match per-arm on BOTH stages (rule-10) and pins