Explorar o código

resolve-check: forward-selector test + step 4b notes

Adds t_fwdsel.mod (a forward module-level array used through an index
selector, which t_fwdvar did not cover) and records step 4b in the plan,
including what remains: propagate resolved types up the expression tree
and move the statement/expression checks into the walk.

Suite 191/191.
Eric Streit hai 2 días
pai
achega
c32970a986
Modificáronse 3 ficheiros con 37 adicións e 0 borrados
  1. 1 0
      compiler/run_tests.sh
  2. 18 0
      compiler/tests/t_fwdsel.mod
  3. 18 0
      docs/plan-resolve-check.md

+ 1 - 0
compiler/run_tests.sh

@@ -84,6 +84,7 @@ expect_run t_constfold.mod 42
 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_emptystat.mod 42
 expect_run t_highlen.mod 18
 expect_run t_builtins.mod 42

+ 18 - 0
compiler/tests/t_fwdsel.mod

@@ -0,0 +1,18 @@
+MODULE TFwdSel;
+// Forward module-level variables used through an array-index selector
+// (t_fwdvar exercises the selector-less case).  Exit 42.
+VAR ExitCode : INTEGER;
+
+PROCEDURE Init;
+BEGIN
+  arr[0] := 41; arr[1] := 1;
+  IF (arr[0] + arr[1]) = 42 THEN ok := TRUE END
+END Init;
+
+VAR arr : ARRAY [0..3] OF INTEGER;
+VAR ok  : BOOLEAN;
+
+BEGIN
+  Init;
+  IF ok THEN ExitCode := 42 ELSE ExitCode := 1 END
+END TFwdSel.

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

@@ -251,4 +251,22 @@ Measured while scaffolding (branch `resolve-check`):
     (`AST.SetTy`) for `Lower` to read.  Designator nodes are the only
     expressions whose parse-time type is `-1` (forward/undefined).
 
+- **2026-10-15 (`192ad55`, step 4b)** — the designator resolver exists:
+  `Check` resolves a *forward* designator's full type — the base symbol
+  (from the scope recorded at reference time) plus its selectors, via
+  `SelType` over `SymTab.FieldType`/`ArrayElem`/`PtrBase` — and stores
+  it on the node with `AST.SetTy`.  `SymTab.FwdVarResolve` now also
+  returns the resolved type, and `Design` attaches the designator node
+  to the forward note.  Verified with a temporary differential
+  instrument in `LowerDesign` (which computes the same type
+  independently): clean across the suite, and it fires (299) when the
+  resolver is deliberately broken.  New regression test `t_fwdsel.mod`
+  (forward ref through an array-index selector).  Suite 191/191;
+  fixpoint OK (3,474,750 bytes).
+- **Next**: forward designators are now typed, but an expression
+  *containing* one (e.g. `arr[0] + arr[1]`) is still typed `InvalidType`
+  at parse time — the walk must propagate the resolved types up the
+  tree and then take over the statement/expression checks.  Only then
+  can `Design` stop deferring and `FwdVar*` go.
+