t_arrfwd.mod 355 B

123456789101112
  1. MODULE TArrFwd;
  2. // An ARRAY whose index type is declared later (a forward type reference):
  3. // its bounds are patched when the TYPE block completes. Exit 42.
  4. TYPE a = ARRAY idx OF INTEGER;
  5. idx = [-2..2];
  6. VAR x : a;
  7. ExitCode : INTEGER;
  8. BEGIN
  9. x[0] := 5;
  10. x[2] := 37;
  11. IF x[0] + x[2] = 42 THEN ExitCode := 42 ELSE ExitCode := 1 END
  12. END TArrFwd.