| 12345678910111213141516171819202122232425262728 |
- MODULE local_array_bug;
- (* MISDIAGNOSED (2026-10-05). The original report said a local ARRAY
- inside a PROCEDURE was miscompiled. The actual cause was the module
- *name*: this grammar's scanner did not accept `_` in identifiers
- (`ident = letter { letter | digit }`), so `local_array_bug` lexed as
- `local` + `_array_bug` and the module body was silently dropped
- (empty `main`).
- FIXED: `M2.atg`'s ident rule now includes "_"
- (`ident = letter { letter | digit | "_" }`), per ISO Modula-2.
- Regression: compiler/tests/t_under.mod.
- Local arrays themselves compile correctly; e.g. with a camelCase
- module name this same program exits 60. See also
- tests/t_lower5arr.mod for local arrays of records and open-array
- arguments. *)
- VAR ExitCode : INTEGER;
- PROCEDURE P;
- VAR a : ARRAY [0..3] OF INTEGER; i : INTEGER;
- BEGIN
- i := 0;
- WHILE i < 4 DO a[i] := i * 10; INC(i) END;
- ExitCode := a[0] + a[1] + a[2] + a[3] (* 0+10+20+30 = 60 *)
- END P;
- BEGIN P END local_array_bug.
|