wwstage: reject error-type vs int comparison (#246)
cstage cbinop routes every comparison through unify_arith (cmd/wcc/check.c:952), which loud-rejects an error-typed operand paired with a differing type (e.g. strconv.invalid != i32). wwstage binoptype returned bool for comparisons without any unify step, so it silently accepted a program cstage rejects -- a rule-10 break (align the leaner-but-leniner wwstage DOWN to cstage). Scope the rejection to an error operand (varianterr) mismatched with the other (typeeqast) so the broad differing-types diagnostic -- whose typeeqast-vs-cstage-type_eq asymmetry risk could reject valid bootstrap code -- stays out of wwstage. Covers the whole comparison family (EQ/NEQ/LT/LE/GT/GE), all of which cstage routes through unify_arith. Found by impl-strconv3 writing the strconv test. Gate-blind: the bootstrap never compares an error type to an int, so byte-id stayed green while the stages disagreed on what's a valid program. test/wcc/949_errtype_compare.c: both drivers reject invalid !=/==/< i32 (K_BUILDERR); same-error-type and plain-int compares still accept on both stages + cs==ww byte-id (K_RUN). 12/12.
This commit is contained in:
7
Makefile
7
Makefile
@@ -293,6 +293,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_overcap_tuple_field_store_run \
|
||||
$(BIN)/test_mixed_scalar_tuple_sret_run \
|
||||
$(BIN)/test_tuple_in_union_run \
|
||||
$(BIN)/test_errtype_compare \
|
||||
$(BIN)/test_tuple_elem_slice_len_run \
|
||||
$(BIN)/test_str_forrange_loopvar_run \
|
||||
$(BIN)/test_composite_call_arg \
|
||||
@@ -1204,6 +1205,12 @@ $(BIN)/test_tuple_in_union_run: test/wcc/940_tuple_in_union_run.c \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_errtype_compare: test/wcc/949_errtype_compare.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_composite_call_arg: test/wcc/723_composite_call_arg.c \
|
||||
$(BIN)/w6c $(BIN)/w6c_ww | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
Reference in New Issue
Block a user