Просмотр исходного кода

language: SET OF <enum> literals

BaseSpanOk accepts an enum base (span <= 256), so a bare set literal
({red, blue}) is assignable to a SET OF <enum> (SetBasesOk then holds).
SetSpan already handled enums. Test t_setenum; suite 222/222; fixpoint
OK; corpus OK unchanged (the corpus files using this hit the separate
forward-type-ref-in-SET case). Status docs refreshed.
Eric Streit 1 день назад
Родитель
Сommit
d76822a28f
5 измененных файлов с 16 добавлено и 4 удалено
  1. 2 2
      README.md
  2. 1 0
      compiler/run_tests.sh
  3. 3 0
      compiler/src/SymTab.mod
  4. 8 0
      compiler/tests/t_setenum.mod
  5. 2 2
      docs/STATUS.md

+ 2 - 2
README.md

@@ -47,8 +47,8 @@ docs/              STATUS.md, plan.md, plan-*.md, analysis_*.md, summary_*.md
 
 ## Status (2026-10-16)
 
-- Suite **221/221**; self-hosting **fixpoint OK** (byte-identical
-  stage2/stage3, 3,729,161 bytes); corpus **381/612 compile-OK,
+- Suite **222/222**; self-hosting **fixpoint OK** (byte-identical
+  stage2/stage3, 3,730,786 bytes); corpus **381/612 compile-OK,
   0 crashes** (`tools/v3-corpus`).
 - Active branch **`resolve-check`** (holds the AST/`Lower`/parse
   refactors and generics).

+ 1 - 0
compiler/run_tests.sh

@@ -93,6 +93,7 @@ expect_run t_builtins.mod 42
 expect_run t_long.mod 42
 expect_run t_truncfloat.mod 42
 expect_run t_enumidx.mod 42
+expect_run t_setenum.mod 42
 expect_run t_unicode.mod 31
 expect_run t_charbounds.mod 3
 expect_run t_record.mod 160

+ 3 - 0
compiler/src/SymTab.mod

@@ -2696,6 +2696,9 @@ PROCEDURE BaseSpanOk (b: TypeIndex): BOOLEAN;
     IF r = InvalidType THEN RETURN TRUE END;
     IF tform[r] = FBool THEN RETURN TRUE END;
     IF tform[r] = FChar THEN RETURN TRUE END;
+    IF (tform[r] = FEnum) AND (tenum[r] >= 1) AND (tenum[r] <= 256) THEN
+      RETURN TRUE   (* a set base over an enumeration *)
+    END;
     IF (tform[r] = FSub) AND (tref[r] = InvalidType)
  AND SubBounds(b, lo, hi) AND (hi >= lo) AND (hi - lo < 256) THEN
       RETURN TRUE

+ 8 - 0
compiler/tests/t_setenum.mod

@@ -0,0 +1,8 @@
+MODULE TSetEnum;
+// SET OF <enum>: an enum-based set type and a bare-set literal.  Exit 42.
+TYPE colour = (red, green, blue);
+VAR s : SET OF colour; ExitCode : INTEGER;
+BEGIN
+  s := {red, blue};
+  IF (red IN s) AND NOT (green IN s) THEN ExitCode := 42 ELSE ExitCode := 1 END
+END TSetEnum.

+ 2 - 2
docs/STATUS.md

@@ -4,9 +4,9 @@ This answers "where are we now?".
 
 ## Numbers
 
-- Suite **221/221** (`compiler/run_tests.sh`).
+- Suite **222/222** (`compiler/run_tests.sh`).
 - Self-hosting **FIXPOINT OK** — stage2 and stage3 images are
-  byte-identical (3,729,161 bytes).
+  byte-identical (3,730,786 bytes).
 - Corpus **381 / 612** sources compile with 0 errors, **0 crashes**
   (`tools/v3-corpus/corpus.sh` over the gm2 testsuite); the rest are
   genuine language gaps or unresolved imports.