diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/SPEC.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/SPEC.md b/docs/SPEC.md index 4936856..32afdfb 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -481,7 +481,7 @@ pn((int)(p + 1) - (int)p); // 1: p + 1 moves one word 3.13.3 `push(a, x)` appends and grows; `pop(a)` removes and returns the last element; `resize(a, n)` sets the length, zero-filling new elements and dropping the rest (freeing owned elements). `push` and `pop` on aggregate element types are errors (push takes scalar or reference elements; use resize for aggregates). `push`, `pop`, `resize` on a `fixed` array: error: a fixed array can't grow or shrink. -3.13.4 indexing (outside unbounded and o3 code, 4.15): `a[i]` with `i < 0` or `i >= len(a)` prints `zy: index I out of range (length N)` on the output and stops the program (`rt.halt`, exit status 0). `pop` on an empty array reports the same with index -1. a constant index known to be out of range also produces a compile-time warning: `zc: line N: warning: out-of-bounds access: index 2 is outside length 2 (storage declared or allocated on line N)`, and the program still runs. +3.13.4 indexing (outside unbounded and o3 code, 4.15): `a[i]` with `i < 0` or `i >= len(a)` prints `zy: index I out of range (length N)` on the output and stops the program (a runtime trap, exit status 2, 8.1.3). `pop` on an empty array reports the same with index -1. a constant index known to be out of range also produces a compile-time warning: `zc: line N: warning: out-of-bounds access: index 2 is outside length 2 (storage declared or allocated on line N)`, and the program still runs. ``` int[?] a = {1, 2}; push(a, 3); a.push(4); @@ -1046,7 +1046,7 @@ changes to the operator and keyword tables take effect for the text read after t 8.1.2 after a unit compiles with no errors, the runtime calls `std.libinit()` if the unit includes `std`, then `main()` if a function `main` is defined (no arguments; it works in a namespaced file too), then stops the machine. a unit with no `main` runs nothing. a unit with errors does not run. -8.1.3 the value `main` returns is discarded. the process exit status of `zy` is 0 in all cases, including compile errors and `rt.halt()`. +8.1.3 the value `main` returns is discarded. the process exit status of `zy` (and `zym`) is 1 after compile errors, 2 after a runtime trap (an index out of range, a stack or frame overflow, out of heap memory, a bad pointer or use after free under memdebug), and 0 otherwise, including `rt.halt()`. 8.1.4 compile errors are printed on standard output (not standard error), the same stream as the program's output. |
