wcc/check: #9 reject explicit [N]=[init] over-fill incl [0] (both stages)
An explicit [N]T = [init] with more initializers than N silently mis-compiled for N==0: the over-fill length-mismatch check was suppressed when alen==0, because alen==0 doubles as the [_] infer-sentinel after resolve_type collapses the two. So def/let [0]int=[1,2] silently resized (cstage exit 2) or OOB-read/segfaulted (wwstage) instead of the loud length-mismatch that [N]=[init>N] gets everywhere else. The AST keeps the distinction the Type loses: [_] leaves the N_TARRAY length-child NULL, an explicit [N] carries N_INTLIT. cstage adds an is_infer_arr() helper, drops the alen>0 exemption at the over-fill check, and gates the 4 infer-resize/no-init sites on is_infer_arr so an explicit [0] flows to the over-fill -> loud. wwstage flips the one shared count gate (checkarrlitfits) from declen>0 to arrtn.rhs!=nil, which also dissolves a wwstage local-resize/module-OOB inconsistency. [_] inference, [0]=[] empty, and [_]-no-init louding all preserved. Under-long (count<N) stays out of scope (#10). byte-id 990-997 8/8. test/wcc/820 table-driven; its one empty-[0] global row carves out byte-id (pre-existing spurious-DATAW divergence, task #15).
This commit is contained in:
7
Makefile
7
Makefile
@@ -248,6 +248,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_def_arr_infer_len \
|
||||
$(BIN)/test_def_arr_len \
|
||||
$(BIN)/test_def_str_table \
|
||||
$(BIN)/test_arr_zero_vs_infer \
|
||||
$(BIN)/test_slice_str_global_zero \
|
||||
$(BIN)/test_slice_literal_global \
|
||||
$(BIN)/test_global_arr_elem_field \
|
||||
@@ -668,6 +669,12 @@ $(BIN)/test_def_str_table: test/wcc/819_def_str_table.c $(BIN)/ww \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_arr_zero_vs_infer: test/wcc/820_arr_zero_vs_infer.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_arr_tagged_elem: test/wcc/685_arr_tagged_elem.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