Quellcode durchsuchen

resolve-check: forward-compound test + step 4c notes

Adds t_fwdprop.mod (a forward variable inside a compound expression) and
records step 4c plus what remains (the checks, still parse-time and
lenient for forwards).  Suite 192/192.
Eric Streit vor 2 Tagen
Ursprung
Commit
f388bcaadc
3 geänderte Dateien mit 35 neuen und 0 gelöschten Zeilen
  1. 1 0
      compiler/run_tests.sh
  2. 17 0
      compiler/tests/t_fwdprop.mod
  3. 17 0
      docs/plan-resolve-check.md

+ 1 - 0
compiler/run_tests.sh

@@ -85,6 +85,7 @@ expect_run t_resultsfx.mod 42
 expect_run t_coroutine.mod 42
 expect_run t_fwdvar.mod 42
 expect_run t_fwdsel.mod 42
+expect_run t_fwdprop.mod 42
 expect_run t_emptystat.mod 42
 expect_run t_highlen.mod 18
 expect_run t_builtins.mod 42

+ 17 - 0
compiler/tests/t_fwdprop.mod

@@ -0,0 +1,17 @@
+MODULE TFwdProp;
+// A forward module-level variable inside a compound expression
+// (`(arr[0] + arr[1]) * 2`): the enclosing nodes are typed InvalidType
+// at parse time and re-typed by the resolve pass.  Exit 42.
+VAR ExitCode : INTEGER;
+
+PROCEDURE SetIt;
+BEGIN z := (arr[0] + arr[1]) * 2 END SetIt;
+
+VAR arr : ARRAY [0..3] OF INTEGER;
+VAR z   : INTEGER;
+
+BEGIN
+  arr[0] := 10; arr[1] := 11;
+  SetIt;
+  ExitCode := z
+END TFwdProp.

+ 17 - 0
docs/plan-resolve-check.md

@@ -269,4 +269,21 @@ Measured while scaffolding (branch `resolve-check`):
   tree and then take over the statement/expression checks.  Only then
   can `Design` stop deferring and `FwdVar*` go.
 
+- **2026-10-15 (`9dc2ed7`, step 4c)** — resolved types now propagate up
+  the expression tree: `Check.PropNode` walks the unit post-order and
+  `EvalExpr` re-types any node still `-1`, combining its operands by the
+  operator rules (reusing `SymTab.ArithCheck`/`RelCheck`/`InCheck`/
+  `BoolCheck`).  Leaf kinds must be skipped — their `child 0` is a text
+  index, not a node (descending into it segfaulted).  First half of the
+  `Lower` split too: string and set literals now read the type the
+  parser stored instead of constructing a second one.  Verified by the
+  differential instrument (compared by class); regression tests
+  `t_fwdsel.mod` and `t_fwdprop.mod`; suite 192/192.
+- **Remaining**: the *checks* themselves (assignment, control flow,
+  calls) are still parse-time and lenient for forwards, so `Design`
+  still defers; moving them into the walk is what finally lets
+  `FwdVar*` go.  The instrument also exposed a pre-existing, harmless
+  divergence: a procedure value's type is `ClProc` at parse time but
+  `ClInvalid` in `Lower`.
+