Report 2026-10.28: an array a call returns lives to its statement's end A defect mended, met writing libro: f()[0..4] kept in a variable read what the next statement put in the temporary, though the report gave the array no end. By the owner's choice the report now says what the compiler does (section 8): the array lives to the end of the statement the call is in, and a slice of it kept past that is undefined, among section 10's exceptions. No code changes; raz says it follows 2026-10.28. The history tells Sys's gains since 10.27.
| @@ -219,6 +219,9 @@ | ||
| 219 | 219 | local slice variable or a record, stored, or come back from a call, |
| 220 | 220 | isn't, and is left undefined (10). `ret` and `keep`, in |
| 221 | 221 | PROPOSALS.md, would close it; the owner keeps it open for now. |
| 222 | +- An array a call returns is a temporary of the statement (report | |
| 223 | + 2026-10.28, 8): a slice of it kept past the statement is undefined | |
| 224 | + (10), and isn't caught. | |
| 222 | 225 | - `Buf.add`, `str` and `spare`, and `Vec`'s growing, stop the program |
| 223 | 226 | when the allocator has no room; `room` asks first. |
| 224 | 227 | - An `extern` module variable is read-only for an importer, as the |
| @@ -514,47 +514,6 @@ | ||
| 514 | 514 | that breaks no program; about ten lines, with a test in `Map`'s |
| 515 | 515 | `main`. |
| 516 | 516 | |
| 517 | -## A slice of an array a call returns, kept | |
| 518 | - | |
| 519 | -A defect, of the report or the compiler, not a wish. `f()[0..4]`, a | |
| 520 | -slice of the array a call returns, is a slice of a temporary of the | |
| 521 | -caller's: the compiler takes the array's place from `allocTemp`, and | |
| 522 | -`releaseTemps` gives it back at the end of the statement. Kept in a | |
| 523 | -variable, the slice outlives it, and reads what the next statement | |
| 524 | -puts there: | |
| 525 | - | |
| 526 | -``` | |
| 527 | -proc f(c: U8): [8]U8; | |
| 528 | -var a: [8]U8; i: INT; | |
| 529 | -begin | |
| 530 | - for i := 0 to 7 do a[i] := c; end; | |
| 531 | - return a; | |
| 532 | -end; | |
| 533 | - | |
| 534 | -proc main*; | |
| 535 | -var s, t: []U8; i: INT; | |
| 536 | -begin | |
| 537 | - s := f('a')[0..4]; | |
| 538 | - for i := 1 to 3 do t := f('b')[0..4]; end; | |
| 539 | - Out.str(s); Out.str(" "); Out.str(t); Out.ln; (* "bbbb" and four blanks *) | |
| 540 | -end; | |
| 541 | -``` | |
| 542 | - | |
| 543 | -The report doesn't say how long a returned array lives. 7.3 makes | |
| 544 | -returning a slice of one an error, as it is the frame's; section 10 | |
| 545 | -leaves undefined only "a slice kept after the call whose frame holds | |
| 546 | -what it points at", and `main`'s call hasn't ended. So by the report | |
| 547 | -`s` is good until `main` returns, and by the compiler it isn't. | |
| 548 | - | |
| 549 | -Either mend closes it: the report says the array lives to the end of | |
| 550 | -the statement, a slice kept past it undefined, with section 10's | |
| 551 | -list; or slicing an array a call returns, anywhere but as an argument | |
| 552 | -or in the expression it is used in, is an error, as 7.3's return of | |
| 553 | -one is. The second is what 7.3 already checks (`Item.frame`), at more | |
| 554 | -places; the first changes nothing but the report. | |
| 555 | - | |
| 556 | -Met writing libro, trying what the report allows; libro doesn't do it. | |
| 557 | - | |
| 558 | 517 | ## Enumerations' names, each its own |
| 559 | 518 | |
| 560 | 519 | An enumeration's names are declared in the scope around its type |
| @@ -1183,6 +1183,9 @@ | ||
| 1183 | 1183 | the epilogue and patches the frame's size in. Within a statement, |
| 1184 | 1184 | scratch space comes from `allocTemp` and is given back by |
| 1185 | 1185 | `releaseTemps`; `allocPerm` reserves space for the whole procedure. |
| 1186 | +An array a call returns is such a temporary, so it lives to the end of | |
| 1187 | +its statement, as the report says (section 8), and a slice of it kept | |
| 1188 | +past that reads what the next statement puts there. | |
| 1186 | 1189 | |
| 1187 | 1190 | Register variables: the parser chooses them (`chooseRegs`, in |
| 1188 | 1191 | Parse.raz), then gives the locals left in memory their slots |
| @@ -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.27 of the report; section 11 says where each | |
| 16 | +This is version 2026-10.28 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 |
| @@ -28,7 +28,9 @@ | ||
| 28 | 28 | reads and writes the bytes of a variable as a `T` (section 6.9); it |
| 29 | 29 | breaks no program. 2026-10.27 mends a defect: returning a slice of the |
| 30 | 30 | procedure's own frame is an error (section 7.3), which breaks only a |
| 31 | -program that read memory already gone. | |
| 31 | +program that read memory already gone. 2026-10.28 mends another: an | |
| 32 | +array a call returns lives to the end of its statement, and a slice of | |
| 33 | +it kept past that is undefined (sections 8 and 10). | |
| 32 | 34 | |
| 33 | 35 | The language is frozen, softly, from this version on: it changes only |
| 34 | 36 | to mend a defect, and its library grows only by what breaks no program |
| @@ -1329,7 +1331,17 @@ | ||
| 1329 | 1331 | procedure that can fail has an `ERROR` as its last result (section |
| 1330 | 1332 | 5.8), which `try` passes on (section 7.8). |
| 1331 | 1333 | |
| 1334 | +An array a call returns lives to the end of the statement the call is | |
| 1335 | +in. A slice of it may be used there, indexed, passed or compared; one | |
| 1336 | +kept past the statement, in a variable or anywhere else, points at | |
| 1337 | +what is gone, and is the exception of section 10: | |
| 1338 | + | |
| 1332 | 1339 | ``` |
| 1340 | +s := f('a')[0..4]; (* f returns a [8]U8: s is undefined after this *) | |
| 1341 | +Out.str(f('a')[0..4]); (* used in its statement: defined *) | |
| 1342 | +``` | |
| 1343 | + | |
| 1344 | +``` | |
| 1333 | 1345 | module Divide; |
| 1334 | 1346 | import Out; |
| 1335 | 1347 | |
| @@ -1483,7 +1495,8 @@ | ||
| 1483 | 1495 | defined by this report, with one exception: memory reached other than |
| 1484 | 1496 | through a checked variable. Dereferencing a stale or made-up pointer, |
| 1485 | 1497 | indexing through a pointer, a slice kept after the call whose frame |
| 1486 | -holds what it points at (section 7.3), an index out of range in a | |
| 1498 | +holds what it points at (section 7.3), a slice of an array a call | |
| 1499 | +returned kept past its statement (section 8), an index out of range in a | |
| 1487 | 1500 | module that says `check off;`, writing a string's bytes, a code procedure that |
| 1488 | 1501 | breaks its rules, and C code can read or write any memory, and what |
| 1489 | 1502 | follows isn't defined. Dereferencing `nil`, dividing |
| @@ -160,3 +160,9 @@ | ||
| 160 | 160 | `Buf` gains `spare`, and its `add` and `str` stop the program when |
| 161 | 161 | memory runs out rather than dropping bytes; the standard library |
| 162 | 162 | gains `Vec`, a growable array (volume 2). |
| 163 | +- **2026-10.28.** A defect mended: an array a call returns lives to the | |
| 164 | + end of the statement the call is in, and a slice of it kept past | |
| 165 | + that is undefined, among the exceptions of section 10 (section 8). | |
| 166 | + `Sys` gains `entryKind` and `Info.dev`; `spawn` finds a name without | |
| 167 | + a `/` along `PATH`; over the C library, `syncAll` of a file that | |
| 168 | + isn't open is -9 (EBADF), as on Linux (volume 2). |
| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | import Sys, Out, Version, Files, Fmt, Diag, Scan, Sym, Chunk, X64, Gen, Parse, Link, Elf; |
| 30 | 30 | |
| 31 | 31 | const |
| 32 | - Report = "2026-10.27"; (* the version of doc/raz.md it follows *) | |
| 32 | + Report = "2026-10.28"; (* the version of doc/raz.md it follows *) | |
| 33 | 33 | MemfdCreate = 319; (* the system call *) |
| 34 | 34 | MfdCloexec = 1; (* an ELF still executes: the kernel opens it first *) |
| 35 | 35 | Execve = 59; |