wcc/ww: reject a duplicate top-level main (F-D)
A second top-level decl named `main` (fn/let/def/type) collides with the entry main on the single bare `main` symbol: today both lower to a bare `main`, w6l silently accepts the duplicate, and the program links rc=0 then segfaults (or runs wrong), in both stages. The existing duplicate-decl rejects key on (name, module), so a cross-module `foo.main` vs the bare entry `main` read as distinct and slip through. Add a program-global, name-only, cross-module uniqueness check on `main` in the checker (both stages), colocated with the duplicate-decl rejects and counting user decls before the -T synthesized test main. Corpus-safe: a lone `fn main` in any package stays legal (ww has no package-main convention -- cmatrix/lisp/mandelbrot are non-main-package entries and keep building). This converts the silent segfault to a loud compile error and subsumes the w6l silent-dup-main case (#31); correct package-aware mangling of a non-entry main is deferred to the root-unit entry-detection work (#22/#32). Regenerates the w6c and wwdump combined.ww. Table-driven 842 test: reject rows for let/fn/def/type main (genuine cross-module import form) plus a negative single-main corpus-safe row that must still build+run.
This commit is contained in:
7
Makefile
7
Makefile
@@ -246,6 +246,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_arr_enum_elem \
|
||||
$(BIN)/test_arr_strslice_elem \
|
||||
$(BIN)/test_arr_tagged_elem \
|
||||
$(BIN)/test_dup_main_reject \
|
||||
$(BIN)/test_arr_infer_len \
|
||||
$(BIN)/test_arr_cap_reject \
|
||||
$(BIN)/test_tagged_subset_reject \
|
||||
@@ -1431,6 +1432,12 @@ $(BIN)/test_arr_tagged_elem: test/wcc/685_arr_tagged_elem.c $(BIN)/ww \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_dup_main_reject: test/wcc/842_dup_main_reject.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_slice_str_global_zero: test/wcc/686_slice_str_global_zero.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