raz / commit fdb79e4b

commit
fdb79e4b87a2fda6f784e087893060b581be54e3
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
1ea1e717
Report 2026-10.30: [] used as a slice is the empty slice

A defect mended: 7.3 made returning [] an error, as an array literal,
which the compiler never was. [] is the empty slice, ptr nil and len
0, and no hidden variable (6.5).

patch · log

2 files changed, +14 -6

doc/raz.md (history) modified +10 -6

@@ -13,7 +13,7 @@
1313 This report defines the language. It is short on purpose. Whatever it
1414 doesn't allow, raz doesn't have.
1515
16-This is version 2026-10.29 of the report; section 11 says where each
16+This is version 2026-10.30 of the report; section 11 says where each
1717 version's changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose,
1818 for a language anyone can build again. They break programs written
1919 for 2026-10.10 and before: for 2026-10.9, say, the report of compiler
@@ -32,7 +32,9 @@
3232 array a call returns lives to the end of its statement, and a slice of
3333 it kept past that is undefined (sections 8 and 10). 2026-10.29 is a
3434 sixth thaw: an array constant typed `[]T` takes its length from its
35-literal (section 4); it breaks no program.
35+literal (section 4); it breaks no program. 2026-10.30 mends a defect:
36+`[]` used as a slice is the empty slice, which may be returned
37+(sections 6.5 and 7.3); it breaks no program.
3638
3739 The language is frozen, softly, from this version on: it changes only
3840 to mend a defect, and its library grows only by what breaks no program
@@ -776,7 +778,9 @@
776778 A record literal names its fields, in any order, each at most once; the
777779 fields it leaves out are zero, so `{}` is the record with every field
778780 zero. An array literal used as a slice is a
779-hidden variable of the procedure, and lives as long as its call.
781+hidden variable of the procedure, and lives as long as its call;
782+the empty one, `[]`, is the empty slice, as a slice variable starts
783+(section 4), and no variable at all.
780784
781785 ```
782786 c := {ch: 'A', attr: 7};
@@ -1052,9 +1056,9 @@
10521056
10531057 A slice returned must not point into the procedure's own frame, which
10541058 is gone once it returns. It is an error to return, as a slice, a local
1055-array, a value parameter that is an array, an array literal, or an
1056-array a call returns, or a slice of one, a field or an element of one
1057-included:
1059+array, a value parameter that is an array, an array literal other than
1060+`[]`, or an array a call returns, or a slice of one, a field or an
1061+element of one included:
10581062
10591063 ```
10601064 proc short(h: Hex): []U8; (* Hex = [64]U8 *)

doc/report-history.md (history) modified +4 -0

@@ -176,3 +176,7 @@
176176 `dupAbove`, `group`, `fork`, `handle` and `came`, and `wait` on a
177177 group; `Map` gains `done`, `Str` gains `free`, and `Files` gains
178178 `load`, and tries again after EINTR (volume 2).
179+- **2026-10.30.** A defect mended: `[]` used as a slice is the empty
180+ slice, `ptr` `nil` and `len` 0, and no hidden variable, so it may be
181+ returned (sections 6.5 and 7.3); 7.3 had made returning it an error,
182+ which the compiler never was. It breaks no program.