refactor: unify the M1-M7 checker

check_m7.c textually included check.c, renamed three entry points aside, and
selected between two whole checkers by scanning each unit for `?`, `!`, `try`
and friends. A unit that mentioned any of them was checked by a second
implementation, so an M1-M6 rule fixed in check.c never reached it -- and the
split hid real defects, since the M7 half was reached by no existing fixture
until M7 cases were registered.

The split was cheaper to undo than it looked: every M7 dispatcher already
delegated to its M6 counterpart for nodes it did not handle. So the M7 entry
points become the single check_expr/check_stmt/check_lvalue/check_call, and
the former M6 bodies become check_expr_core/check_stmt_core/check_lvalue_core,
reached as the fallback. Recursion runs through the unified entry, which is
what makes an optional nested inside otherwise-M6 code get checked at all.

m7_check_fn and m7_check_method were identical to the M6 versions apart from
which check_stmt they called, so they are dropped. The feature scanner
(m7_type_ast, m7_node_feature, m7_program_feature) is gone with the dispatch
it fed, including the loop case that still consulted it. fe_check_program and
fe_check_expr_type keep the M7 bodies, which are supersets.

The build compiles check.c directly again.

No behaviour intended to change: the unified checker applies the union of the
rules to every unit, which for M1-M6 sources is what the M6 half already did.
This commit is contained in:
2026-08-17 01:45:04 +09:00
parent d5e7a8d8d6
commit 3091df7a78
4 changed files with 1009 additions and 1214 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
CC ?= cc
CFLAGS ?= -O2 -Wall -Wextra -std=c89
CPPFLAGS ?= -Isrc
SRC = src/arena.c src/diag.c src/lexer.c src/ast.c src/parser.c src/types.c src/m7.c src/own.c src/check_m7.c src/lower.c src/emitcm7.c src/driver.c
SRC = src/arena.c src/diag.c src/lexer.c src/ast.c src/parser.c src/types.c src/m7.c src/own.c src/check.c src/lower.c src/emitcm7.c src/driver.c
OBJ = $(SRC:.c=.o)
.PHONY: all clean dos-build
+1 -1
View File
@@ -27,7 +27,7 @@ wcl -q -za -wx -bt=dos -ml -k32768 -c -fo=m7.obj src\m7.c
if errorlevel 1 goto build_fail
wcl -q -za -wx -bt=dos -ml -k32768 -c -fo=own.obj src\own.c
if errorlevel 1 goto build_fail
wcl -q -za -wx -bt=dos -ml -k32768 -c -fo=check.obj src\check_m7.c
wcl -q -za -wx -bt=dos -ml -k32768 -c -fo=check.obj src\check.c
if errorlevel 1 goto build_fail
wcl -q -za -wx -bt=dos -ml -k32768 -c -fo=lower.obj src\lower.c
if errorlevel 1 goto build_fail
+969 -20
View File
File diff suppressed because it is too large Load Diff
-1154
View File
File diff suppressed because it is too large Load Diff