| | @@ -13,7 +13,7 @@ |
| 13 | 13 | This report defines the language. It is short on purpose. Whatever it |
| 14 | 14 | doesn't allow, raz doesn't have. |
| 15 | 15 | |
| 16 | | -This is version 2026-10.26 of the report; section 11 says where each |
| 16 | +This is version 2026-10.27 of the report; section 11 says where each |
| 17 | 17 | version's changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose, |
| 18 | 18 | for a language anyone can build again. They break programs written |
| 19 | 19 | for 2026-10.10 and before: for 2026-10.9, say, the report of compiler |
| | @@ -26,7 +26,9 @@ |
| 26 | 26 | is a fifth: an `INT` widens to an `I64` wherever it goes to one, in |
| 27 | 27 | an expression too (sections 5.10 and 6.1); and a view, `v.(T)`, |
| 28 | 28 | reads and writes the bytes of a variable as a `T` (section 6.9); it |
| 29 | | -breaks no program. |
| 29 | +breaks no program. 2026-10.27 mends a defect: returning a slice of the |
| 30 | +procedure's own frame is an error (section 7.3), which breaks only a |
| 31 | +program that read memory already gone. |
| 30 | 32 | |
| 31 | 33 | The language is frozen, softly, from this version on: it changes only |
| 32 | 34 | to mend a defect, and its library grows only by what breaks no program |
| | @@ -1034,6 +1036,26 @@ |
| 1034 | 1036 | procedure with results that runs off its end returns zeros, each result |
| 1035 | 1037 | as a variable of its type starts (section 4). |
| 1036 | 1038 | |
| 1039 | +A slice returned must not point into the procedure's own frame, which |
| 1040 | +is gone once it returns. It is an error to return, as a slice, a local |
| 1041 | +array, a value parameter that is an array, or an array literal, or a |
| 1042 | +slice of one, a field or an element of one included: |
| 1043 | + |
| 1044 | +``` |
| 1045 | +proc short(h: Hex): []U8; (* Hex = [64]U8 *) |
| 1046 | +begin |
| 1047 | + return h[0..8]; (* an error: h is the procedure's copy *) |
| 1048 | +end; |
| 1049 | +``` |
| 1050 | + |
| 1051 | +A slice of a `var` parameter, of a module variable, or of what a |
| 1052 | +pointer points at may be returned: none of them is this procedure's |
| 1053 | +frame. A slice of a frame that leaves it some other way isn't caught, |
| 1054 | +and is the exception of section 10: one held in a local slice |
| 1055 | +variable, or in a record, that is returned; one stored in a module |
| 1056 | +variable or through a pointer; and one that came back from a call, as |
| 1057 | +the slice of a `var` parameter does to the caller whose local it is. |
| 1058 | + |
| 1037 | 1059 | ### 7.4 Match |
| 1038 | 1060 | |
| 1039 | 1061 | ``` |
| | @@ -1459,8 +1481,9 @@ |
| 1459 | 1481 | and indexing arrays and slices is checked, so a program's behaviour is |
| 1460 | 1482 | defined by this report, with one exception: memory reached other than |
| 1461 | 1483 | through a checked variable. Dereferencing a stale or made-up pointer, |
| 1462 | | -indexing through a pointer, an index out of range in a module that |
| 1463 | | -says `check off;`, writing a string's bytes, a code procedure that |
| 1484 | +indexing through a pointer, a slice kept after the call whose frame |
| 1485 | +holds what it points at (section 7.3), an index out of range in a |
| 1486 | +module that says `check off;`, writing a string's bytes, a code procedure that |
| 1464 | 1487 | breaks its rules, and C code can read or write any memory, and what |
| 1465 | 1488 | follows isn't defined. Dereferencing `nil`, dividing |
| 1466 | 1489 | by zero, calling a `nil` procedure and running out of stack stop the |
| | @@ -1565,7 +1588,7 @@ |
| 1565 | 1588 | language, reals aside, is the core of the library: `Rt`, `Out`, `Mem`, |
| 1566 | 1589 | `Arena`, `Lock`, `Str` and `Buf`, and of `Sys` what they need. A program |
| 1567 | 1590 | that keeps to the core runs on every target. The rest of the library |
| 1568 | | -(`Heap`, `Fmt`, `List`, `Map`, `Sort`, `Math`, `Files`, `Opt` and the |
| 1591 | +(`Heap`, `Fmt`, `List`, `Map`, `Vec`, `Sort`, `Math`, `Files`, `Opt` and the |
| 1569 | 1592 | rest of `Sys`) is the standard library: a target may leave a module |
| 1570 | 1593 | out, and one that has it gives what `doc/raz-lib.md` says. `conform/` tests |
| 1571 | 1594 | the core only. |