wcc/ww: reject reassignment of a const binding (catB-22)
The sym carried an is_const flag (lib/ww/sym.ww) but wwstage never set it at the let-install nor consumed it at assignment, so mutating a `const` slipped through silently. Mirror cstage's two sites: set is_const when n.op == TK_CONST at the local let-install (cmd/wcc/ check.c:2408) and reject an N_ASSIGN whose lhs ident resolves to an is_const sym (cmd/wcc/check.c:1889-1896). cstage already rejected; this aligns wwstage's w6c_ww UP. A bare `_` discard lvalue (empty str) is skipped. Regen w6c/wwdump combined.ww (checker embeds in both). Valid-program codegen unchanged → cs==ww byte-id gate stays green.
This commit is contained in:
7
Makefile
7
Makefile
@@ -249,6 +249,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_dup_main_reject \
|
||||
$(BIN)/test_tuple_trailing_comma_reject \
|
||||
$(BIN)/test_voidless_return_reject \
|
||||
$(BIN)/test_const_reassign_reject \
|
||||
$(BIN)/test_size_untyped_int \
|
||||
$(BIN)/test_tagged_staticinit \
|
||||
$(BIN)/test_arr_infer_len \
|
||||
@@ -1463,6 +1464,12 @@ $(BIN)/test_voidless_return_reject: test/wcc/846_voidless_return_reject.c $(BIN)
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_const_reassign_reject: test/wcc/847_const_reassign_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_tagged_staticinit: test/wcc/843_tagged_staticinit.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