Report 2026-10.37 is the rule: the old forms are errors, -strict and RAZ_STRICT gone What SYSTEM fences is refused outside a module that imports it, and extern, link, check off and code procedures are said and read on, so a missing import is one error; the bare ADR, PTR, SYSCALL and ARGV, an atomic given a pointer, a string or a constant's slice into a []U8, and MSG into one are refused with help. The old branches are gone from Item and Parse. conform/err gains a test of each.
| @@ -95,8 +95,9 @@ | ||
| 95 | 95 | mode. Every old form is still taken: a literal into a `[]U8`, the bare |
| 96 | 96 | built-ins, what `SYSTEM` fences without it, an atomic given `ADR(x)`. |
| 97 | 97 | `BOOT` names v0.23.0 (2026-10-26), so `src/` and the library it imports |
| 98 | -may use all of 10.37; v0.24.0 makes the old forms errors and mends | |
| 99 | -`~/r`. CI couldn't run for it either; `make dist` made its tarball here. | |
| 98 | +may use all of 10.37. On main since 2026-10-26, for v0.24.0, the old | |
| 99 | +forms are errors, and `lib/`, `src/`, the tools and the tests are | |
| 100 | +mended; the programs in `~/r` come next. CI couldn't run for it either; `make dist` made its tarball here. | |
| 100 | 101 | v0.22.0, report 2026-10.36, before it, is the twelfth thaw, what `PROPOSALS.md` |
| 101 | 102 | collated: `MIN`, `MAX`, `ABS`, `CLZ`, `CTZ`, `POPCOUNT`, `INT(b)`, |
| 102 | 103 | `OFFSET`, `SIZE(T.f)`, `BYTES` and `FILL`; a qualified case in an arm, |
| @@ -386,18 +387,15 @@ | ||
| 386 | 387 | - `CAS(v, old, new)`, `XCHG(v, x)` and `XADD(v, x)` (report 2026-10.37) |
| 387 | 388 | take a variable, whose address is pushed as `ADR`'s is (`atomic`); a |
| 388 | 389 | local named in one is kept out of a register, as for `ADR` |
| 389 | - (`chooseRegs`). A pointer that isn't a variable, `ADR(x)`, is still | |
| 390 | - taken as the old form until v0.24.0; a pointer variable is the new | |
| 391 | - form, so `XADD(p, 1)` is an error whose help says `p^`. | |
| 392 | -- `raz -strict` (temporary, until v0.24.0 makes it the default) refuses | |
| 393 | - every old form of report 2026-10.37: see `doc/compiler.md`. The | |
| 394 | - library and every program are mended against it first. | |
| 390 | + (`chooseRegs`). A pointer that isn't a variable, `ADR(x)`, is refused | |
| 391 | + with help, and so is a pointer variable, `XADD(p, 1)`, whose help says | |
| 392 | + `p^`. | |
| 395 | 393 | - `import SYSTEM` (report 2026-10.37) binds to `Sym.system`, no file, |
| 396 | 394 | whose scope holds `ADR`, `PTR`, `SYSCALL` and `ARGV`; it is never |
| 397 | - warned of as unused, and an alias is refused. In v0.23.0 nothing is | |
| 398 | - fenced yet: the bare built-ins, pointer arithmetic and conversions, | |
| 399 | - views, `extern`, `link`, code procedures and `check off;` are taken | |
| 400 | - in any module, until v0.24.0. | |
| 395 | + warned of as unused, and an alias is refused. What it fences | |
| 396 | + (`Item.needSystem`, `doc/compiler.md`) is refused elsewhere: `extern`, | |
| 397 | + `link`, code procedures and `check off;` are said and read on, so one | |
| 398 | + missing import is one error. | |
| 401 | 399 | - `[]const T` (report 2026-10.37) is a slice type with `rdonly` set: not |
| 402 | 400 | the same as `[]T`, which goes into it with no code (`coerce`), never |
| 403 | 401 | back (help says why). An element read through one has the item's |
| @@ -406,9 +404,10 @@ | ||
| 406 | 404 | and `FILL` refuse one as their destination (`destSlice`); a slice of |
| 407 | 405 | one, or of an array read through one or of another module's array, |
| 408 | 406 | is one (`slice`); `BYTES` of one is a `[]const U8`; `match` on an |
| 409 | - element gives names only read. Until v0.24.0 a string literal, a | |
| 410 | - constant's slice, `MSG` and a `const` parameter's array keep their | |
| 411 | - old types, `[]U8` and `[]T`. | |
| 407 | + element gives names only read. A string literal (`tConstBytes` where | |
| 408 | + indexed), a constant's slice (`ofConst`), `MSG` and a slice of a | |
| 409 | + `const` parameter's array are `[]const`; a constant's slice part must | |
| 410 | + be declared `[]const`. | |
| 412 | 411 | - `ROL(x, n)` and `ROR(x, n)` (report 2026-10.35) are done at `x`'s |
| 413 | 412 | own width, `rol al, cl` for a `U8`, with no mask of the count: x86 |
| 414 | 413 | takes it modulo 32 or 64, and a byte's or a word's rotation goes |
| @@ -92,7 +92,9 @@ | ||
| 92 | 92 | and v0.23.0; 35 pages. No rewriting tool, by the owner's word: |
| 93 | 93 | v0.24.0's errors point at each place to mend. |
| 94 | 94 | 3. `BOOT` moved to v0.23.0, a step of its own. **Done** 2026-10-26. |
| 95 | -4. **v0.24.0, which enforces it.** `lib/`, `src/`, `tools/`, | |
| 95 | +4. **v0.24.0, which enforces it.** Steps 1 to 3 done 2026-10-26: `raz -strict` | |
| 96 | + first, `lib/`, `src/`, the tools and tests mended against it by | |
| 97 | + agents, then the old forms made errors and the option gone. `lib/`, `src/`, `tools/`, | |
| 96 | 98 | `examples/` and the tests mended where the old forms, made errors, |
| 97 | 99 | are found (`ADR` at a parameter only dereferenced becomes `var` or |
| 98 | 100 | `const`; `SYSTEM.` where an address is kept); the programs in `~/r` |
| @@ -0,0 +1,12 @@ | ||
| 1 | +(* An atomic takes the variable, not a pointer to it (report 6.8). *) | |
| 2 | +module AtomicPointer; | |
| 3 | +import SYSTEM; | |
| 4 | + | |
| 5 | +var n: INT; | |
| 6 | + | |
| 7 | +proc main*; | |
| 8 | +begin | |
| 9 | + _ := XADD(SYSTEM.ADR(n), 1); | |
| 10 | +end; | |
| 11 | + | |
| 12 | +end AtomicPointer. |
| @@ -0,0 +1,13 @@ | ||
| 1 | +(* A slice of an array constant is a []const T (report 4). *) | |
| 2 | +module ConstArrayToSlice; | |
| 3 | + | |
| 4 | +const Primes: [3]INT = [2, 3, 5]; | |
| 5 | + | |
| 6 | +proc main*; | |
| 7 | +var s: []INT; | |
| 8 | +begin | |
| 9 | + s := Primes; | |
| 10 | + s[0] := 0; | |
| 11 | +end; | |
| 12 | + | |
| 13 | +end ConstArrayToSlice. |
| @@ -0,0 +1,13 @@ | ||
| 1 | +(* An error's message is a []const U8 (report 6.8). *) | |
| 2 | +module MsgToSlice; | |
| 3 | + | |
| 4 | +const Oops: ERROR = "oops"; | |
| 5 | + | |
| 6 | +proc main*; | |
| 7 | +var s: []U8; | |
| 8 | +begin | |
| 9 | + s := MSG(Oops); | |
| 10 | + s[0] := 0; | |
| 11 | +end; | |
| 12 | + | |
| 13 | +end MsgToSlice. |
| @@ -0,0 +1,12 @@ | ||
| 1 | +(* A string is a []const U8, and doesn't go into a []U8, which could | |
| 2 | + write its constant bytes (report 5.10). *) | |
| 3 | +module StringToSlice; | |
| 4 | + | |
| 5 | +proc main*; | |
| 6 | +var s: []U8; | |
| 7 | +begin | |
| 8 | + s := "abc"; | |
| 9 | + s[0] := 0; | |
| 10 | +end; | |
| 11 | + | |
| 12 | +end StringToSlice. |
| @@ -0,0 +1,14 @@ | ||
| 1 | +(* A pointer moved by arithmetic needs import SYSTEM (report 3, 6.4). *) | |
| 2 | +module SystemArith; | |
| 3 | + | |
| 4 | +proc next(p: ^INT): ^INT; | |
| 5 | +begin | |
| 6 | + return p + 1; | |
| 7 | +end; | |
| 8 | + | |
| 9 | +proc main*; | |
| 10 | +begin | |
| 11 | + _ := next(nil); | |
| 12 | +end; | |
| 13 | + | |
| 14 | +end SystemArith. |
| @@ -0,0 +1,13 @@ | ||
| 1 | +(* ADR is SYSTEM.ADR, in a module that imports SYSTEM (report 3, 6.8). *) | |
| 2 | +module SystemBareAdr; | |
| 3 | + | |
| 4 | +var n: INT; | |
| 5 | + | |
| 6 | +proc main*; | |
| 7 | +var p: ^INT; | |
| 8 | +begin | |
| 9 | + p := ADR(n); | |
| 10 | + p^ := 1; | |
| 11 | +end; | |
| 12 | + | |
| 13 | +end SystemBareAdr. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +(* check off; needs import SYSTEM (report 3). *) | |
| 2 | +module SystemCheckOff; | |
| 3 | +check off; | |
| 4 | + | |
| 5 | +proc main*; | |
| 6 | +begin | |
| 7 | +end; | |
| 8 | + | |
| 9 | +end SystemCheckOff. |
| @@ -0,0 +1,11 @@ | ||
| 1 | +(* An integer made a pointer needs import SYSTEM (report 3, 6.7). *) | |
| 2 | +module SystemConvert; | |
| 3 | + | |
| 4 | +proc main*; | |
| 5 | +var p: ^INT; | |
| 6 | +begin | |
| 7 | + p := ^INT(4096); | |
| 8 | + p^ := 0; | |
| 9 | +end; | |
| 10 | + | |
| 11 | +end SystemConvert. |
| @@ -0,0 +1,11 @@ | ||
| 1 | +(* A procedure of C needs import SYSTEM (report 3, 9). *) | |
| 2 | +module SystemExtern; | |
| 3 | + | |
| 4 | +extern proc getpid(): I32; | |
| 5 | + | |
| 6 | +proc main*; | |
| 7 | +begin | |
| 8 | + _ := getpid(); | |
| 9 | +end; | |
| 10 | + | |
| 11 | +end SystemExtern. |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # Reading the raz compiler |
| 2 | 2 | |
| 3 | -The compiler is eleven files of raz, about 12,600 lines of code (the | |
| 3 | +The compiler is eleven files of raz, about 12,700 lines of code (the | |
| 4 | 4 | budget is 14,000). It is its own compiler: a release of it, the one |
| 5 | 5 | `BOOT` names, builds `src/`, and `make fixpoint` checks that what it |
| 6 | 6 | makes makes itself again, byte for byte. Each release was built by the |
| @@ -16,17 +16,17 @@ | ||
| 16 | 16 | |
| 17 | 17 | | File | Lines | Code | What | |
| 18 | 18 | |---|---|---|---| |
| 19 | -| `src/Diag.raz` | 422 | 324 | Messages: positions, source excerpts, colour, counts | | |
| 20 | -| `src/Scan.raz` | 1,169 | 965 | Symbols, literals, comments, positions | | |
| 21 | -| `src/Sym.raz` | 792 | 633 | Types, objects, scopes, layout | | |
| 22 | -| `src/Chunk.raz` | 363 | 279 | The compiled program: chunks, fixups, line notes | | |
| 23 | -| `src/X64.raz` | 1,620 | 1,329 | The instruction encoder, jumps within a procedure, the assembler | | |
| 24 | -| `src/Gen.raz` | 2,840 | 1,986 | The stack machine, for x86-64: values, operations, checks, calls, frames | | |
| 25 | -| `src/Item.raz` | 2,501 | 2,006 | Items: types, constants, variables, operators, conversions, calls | | |
| 26 | -| `src/Parse.raz` | 4,797 | 4,084 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 27 | -| `src/Link.raz` | 407 | 315 | Tree shaking, layout, patching, the places | | |
| 28 | -| `src/Elf.raz` | 449 | 355 | Static and dynamic ELF, symbol table, line numbers | | |
| 29 | -| `src/Raz.raz` | 418 | 333 | The command line | | |
| 19 | +| `src/Diag.raz` | 423 | 325 | Messages: positions, source excerpts, colour, counts | | |
| 20 | +| `src/Scan.raz` | 1,170 | 966 | Symbols, literals, comments, positions | | |
| 21 | +| `src/Sym.raz` | 815 | 652 | Types, objects, scopes, layout | | |
| 22 | +| `src/Chunk.raz` | 364 | 280 | The compiled program: chunks, fixups, line notes | | |
| 23 | +| `src/X64.raz` | 1,621 | 1,330 | The instruction encoder, jumps within a procedure, the assembler | | |
| 24 | +| `src/Gen.raz` | 2,841 | 1,987 | The stack machine, for x86-64: values, operations, checks, calls, frames | | |
| 25 | +| `src/Item.raz` | 2,553 | 2,051 | Items: types, constants, variables, operators, conversions, calls | | |
| 26 | +| `src/Parse.raz` | 4,806 | 4,093 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 27 | +| `src/Link.raz` | 408 | 316 | Tree shaking, layout, patching, the places | | |
| 28 | +| `src/Elf.raz` | 450 | 356 | Static and dynamic ELF, symbol table, line numbers | | |
| 29 | +| `src/Raz.raz` | 419 | 334 | The command line | | |
| 30 | 30 | |
| 31 | 31 | Every file opens with a comment that says what it is, what it depends |
| 32 | 32 | on and what it leaves out. Read those first; they are the map. |
| @@ -1885,17 +1885,18 @@ | ||
| 1885 | 1885 | which its type's fingerprint has. |
| 1886 | 1886 | |
| 1887 | 1887 | Last, modules, at the end of the file. `compileFile` reads one module. |
| 1888 | -`raz -strict`, until v0.24.0 makes it the rule, holds report 2026-10.37 | |
| 1889 | -whole (`Item.strict`): `needSystem` refuses, in a module whose | |
| 1890 | -`Sym.Module.system` isn't set, a pointer's arithmetic, indexing and | |
| 1888 | +What report 2026-10.37 fences behind `import SYSTEM` is refused by | |
| 1889 | +`needSystem` in a module whose `Sym.Module.system` isn't set: a pointer's arithmetic, indexing and | |
| 1891 | 1890 | slicing, pointer and procedure conversions, views and `BYTES` that make |
| 1892 | 1891 | or change an address (`Sym.isPlain`, the item's `viewOver`, checked in |
| 1893 | 1892 | `notReadOnly`), a string as a `^U8`, `extern`, `link`, `check off` and |
| 1894 | -code procedures; `builtin` refuses `ADR`, `PTR`, `SYSCALL` and `ARGV` | |
| 1895 | -not reached through `SYSTEM` (their objects' `home` tells them apart); | |
| 1896 | -a string, a slice of a constant, `MSG` and a slice of a `const` | |
| 1897 | -parameter's array are `[]const`; and an atomic given a pointer is | |
| 1898 | -refused. | |
| 1893 | +code procedures (the last four reported and the declaration read on, | |
| 1894 | +so that one missing import is one error). `builtin` refuses `ADR`, | |
| 1895 | +`PTR`, `SYSCALL` and `ARGV` not reached through `SYSTEM` (their | |
| 1896 | +objects' `home` tells them apart). A string, a slice of a constant, | |
| 1897 | +`MSG` and a slice of a `const` parameter's array are `[]const`. raz | |
| 1898 | +0.23 took all of it, under an option `-strict` to refuse it while the | |
| 1899 | +library and the programs were mended; 0.24 has no other way. | |
| 1899 | 1900 | |
| 1900 | 1901 | `import SYSTEM` (report 2026-10.37) finds no file: the import binds the |
| 1901 | 1902 | name to `Sym.system`, a module made once in `Sym`'s body whose scope |
| @@ -1904,8 +1905,7 @@ | ||
| 1904 | 1905 | export and `builtin` compiles it as `ADR`. It is marked used at the |
| 1905 | 1906 | import, since a module may import it only for `extern` or `link`. An |
| 1906 | 1907 | alias, `import S := SYSTEM`, is refused, so a grep finds every such |
| 1907 | -module. Until v0.24.0 nothing needs it: the bare built-ins and the rest | |
| 1908 | -it fences are still taken anywhere. | |
| 1908 | +module. | |
| 1909 | 1909 | |
| 1910 | 1910 | `importModule` finds a module's file, trying the target's names first, |
| 1911 | 1911 | and compiles it if it isn't yet. A module found in an `-I` or |
| @@ -1990,7 +1990,7 @@ | ||
| 1990 | 1990 | does: `atomic` pushes its address, as `ADR` would, and `Gen.atomic` |
| 1991 | 1991 | works through it as before, so the code is the same as for |
| 1992 | 1992 | `XADD(ADR(n), 1)`. A first argument that is a pointer but no variable, |
| 1993 | -`ADR(n)`, is the form before 10.37, kept until v0.24.0. Since the | |
| 1993 | +`ADR(n)`, the form before 10.37, is refused with help. Since the | |
| 1994 | 1994 | address is taken, `chooseRegs` keeps a local named in one in memory, |
| 1995 | 1995 | as it does one named in `ADR`. |
| 1996 | 1996 |
| @@ -76,7 +76,7 @@ | ||
| 76 | 76 | 10 says what is left undefined outside such modules. It breaks a |
| 77 | 77 | program that gives an atomic a pointer, writes through a string or a |
| 78 | 78 | constant, or does what `SYSTEM` holds without importing it; raz 0.23 |
| 79 | -still takes all of these as before, until 0.24. | |
| 79 | +still took them, as before; raz 0.24 doesn't. | |
| 80 | 80 | |
| 81 | 81 | The language is frozen, softly, from this version on: it changes only |
| 82 | 82 | to mend a defect, and its library grows only by what breaks no program |
| @@ -268,15 +268,15 @@ | ||
| 268 | 268 | And `CAS`, `XCHG` and `XADD` take the variable they work on, as `INC` |
| 269 | 269 | does, not a pointer to it (section 6.8): `XADD(count, 1)`, |
| 270 | 270 | `XADD(p^, 1)`. It breaks a program that gives them a pointer; raz |
| 271 | - 0.23 still takes one that isn't a variable, `ADR(x)`, until 0.24. | |
| 271 | + 0.23 still took one that isn't a variable, `ADR(x)`; 0.24 doesn't. | |
| 272 | 272 | And `[]const T`, a slice whose elements can't be written through it |
| 273 | 273 | (section 5.3): a `[]T` or an array goes where one is wanted, never |
| 274 | 274 | the other way. A string literal and a slice of a constant are |
| 275 | 275 | `[]const`, as `MSG` and a slice of a `const` parameter's array are, |
| 276 | 276 | so writing them is an error, not undefined; another module's exported |
| 277 | 277 | array may be read as one (sections 3, 4, 5.10, 6.8 and 8). It breaks |
| 278 | - a program that writes through these; raz 0.23 still gives them their | |
| 279 | - old types until 0.24. | |
| 278 | + a program that writes through these; raz 0.23 still gave them their | |
| 279 | + old types; 0.24 doesn't. | |
| 280 | 280 | And `import SYSTEM` (section 3): a module the language gives, with no |
| 281 | 281 | file, that a module imports, by that name only, to reach memory other |
| 282 | 282 | than through its variables: `SYSTEM.ADR`, `SYSTEM.PTR`, |
| @@ -287,4 +287,4 @@ | ||
| 287 | 287 | and 9). Section 10 says what is left undefined outside such modules, |
| 288 | 288 | and 7.6 that a race on a pointer, a slice or a variant is undefined. |
| 289 | 289 | It breaks every module that does these without it; raz 0.23 still |
| 290 | - takes them, and the built-ins unprefixed, until 0.24. | |
| 290 | + took them, and the built-ins unprefixed; 0.24 doesn't. |
| @@ -84,8 +84,6 @@ | ||
| 84 | 84 | procedure is compiled again, the variable in memory *) |
| 85 | 85 | checks*: BOOL; (* the module's index and slice checks are made: it |
| 86 | 86 | doesn't say check off *) |
| 87 | - strict*: BOOL; (* raz -strict: report 2026-10.37 held whole, as v0.24.0 | |
| 88 | - will hold it; until then, its old forms are taken *) | |
| 89 | 87 | result: ^Sym.Type; (* the result of the procedure being compiled, or nil *) |
| 90 | 88 | passing: ^Sym.Obj; (* the parameter the argument at passingAt goes to *) |
| 91 | 89 | passingAt: Diag.Pos; |
| @@ -100,11 +98,6 @@ | ||
| 100 | 98 | checks := yes; |
| 101 | 99 | end; |
| 102 | 100 | |
| 103 | -proc setStrict*(yes: BOOL); | |
| 104 | -begin | |
| 105 | - strict := yes; | |
| 106 | -end; | |
| 107 | - | |
| 108 | 101 | (* The comparison that holds when op doesn't *) |
| 109 | 102 | proc negated(op: Scan.Sym): Scan.Sym; |
| 110 | 103 | begin |
| @@ -138,12 +131,11 @@ | ||
| 138 | 131 | return Diag.say(f, [Fmt.str(a)]); |
| 139 | 132 | end; |
| 140 | 133 | |
| 141 | -(* Under -strict, what reaches memory other than through a variable, | |
| 142 | - what, is refused at pos in a module that doesn't import SYSTEM | |
| 143 | - (report 3) *) | |
| 134 | +(* What reaches memory other than through a variable, what, is refused | |
| 135 | + at pos in a module that doesn't import SYSTEM (report 3) *) | |
| 144 | 136 | proc needSystem*(pos: Diag.Pos; what: []const U8): ERROR; |
| 145 | 137 | begin |
| 146 | - if strict and not Sym.curModule^.system then | |
| 138 | + if not Sym.curModule^.system then | |
| 147 | 139 | return Scan.markHelp(pos, say1("{} needs import SYSTEM", what), |
| 148 | 140 | "it reaches memory other than through a variable: say import SYSTEM after the module's imports"); |
| 149 | 141 | end; |
| @@ -641,7 +633,7 @@ | ||
| 641 | 633 | if x.mode = mCond then try value(x); end; |
| 642 | 634 | s := x.typ; |
| 643 | 635 | if x.mode = mStr then |
| 644 | - if strict and (t^.form = Sym.fSlice) and (t^.base = Sym.tU8) and not t^.rdonly then | |
| 636 | + if (t^.form = Sym.fSlice) and (t^.base = Sym.tU8) and not t^.rdonly then | |
| 645 | 637 | return mismatchHelp(x, say1("a string is a []const U8, not {}", Sym.typeName(t)), |
| 646 | 638 | "its bytes are constant: take a []const U8 where they are only read, or copy them"); |
| 647 | 639 | end; |
| @@ -683,10 +675,10 @@ | ||
| 683 | 675 | return mismatchHelp(x, say2("can't use {} as {}", Sym.typeName(s), Sym.typeName(t)), |
| 684 | 676 | "its elements are only read, and a []T could write them"); |
| 685 | 677 | elsif (s^.form = Sym.fArray) and (t^.form = Sym.fSlice) and Sym.same(s^.base, t^.base) then |
| 686 | - (* a slice of what is only read may be made, to read, as of a | |
| 687 | - constant; another module's array, or one read through a | |
| 688 | - []const, only as a []const *) | |
| 689 | - if strict and (onlyRead(x) or ofConst(x)) and not t^.rdonly then | |
| 678 | + (* a slice of what is only read, a constant or a const parameter, | |
| 679 | + another module's array, or one read through a []const, is made | |
| 680 | + only as a []const *) | |
| 681 | + if (onlyRead(x) or ofConst(x)) and not t^.rdonly then | |
| 690 | 682 | return mismatchHelp(x, say2("can't use {} as {}", Sym.typeName(s), Sym.typeName(t)), |
| 691 | 683 | say1("{} is only read: a slice of it is a []const", Diag.source(x.pos))); |
| 692 | 684 | end; |
| @@ -695,7 +687,7 @@ | ||
| 695 | 687 | [Fmt.str(Diag.source(x.pos)), Fmt.str(Scan.nameOf(x.obj^.home^.name))]), |
| 696 | 688 | say1("it may be read as a {}", Sym.typeName(constOf(t)))); |
| 697 | 689 | end; |
| 698 | - if not onlyRead(x) and not t^.rdonly then try notReadOnly(x); end; | |
| 690 | + if not t^.rdonly then try notReadOnly(x); end; | |
| 699 | 691 | if x.vol then return Scan.markAt(x.pos, "can't make a slice through a volatile pointer"); end; |
| 700 | 692 | if x.odd then return Scan.markAt(x.pos, "can't make a slice of a field of a packed record"); end; |
| 701 | 693 | if x.view then return noAddress(x, "can't make a slice of a view"); end; |
| @@ -805,7 +797,7 @@ | ||
| 805 | 797 | begin |
| 806 | 798 | nilTest(x); |
| 807 | 799 | if x.mode = mStr then |
| 808 | - if strict then try coerce(x, Sym.tConstBytes); else try coerce(x, Sym.tBytes); end; | |
| 800 | + try coerce(x, Sym.tConstBytes); | |
| 809 | 801 | end; |
| 810 | 802 | if (x.typ^.form = Sym.fPtr) and (x.typ^.base^.form = Sym.fArray) then |
| 811 | 803 | return Scan.markAt(x.pos, "a pointer to an array is indexed as p^[i]"); |
| @@ -891,7 +883,7 @@ | ||
| 891 | 883 | []const, is a []const; of a const parameter's, a slice to read *) |
| 892 | 884 | roSlice := (t^.form = Sym.fSlice) and t^.rdonly; |
| 893 | 885 | if t^.form = Sym.fArray then |
| 894 | - roSlice := (x.ro and not onlyRead(x)) or x.elemRo or (strict and (onlyRead(x) or ofConst(x))); | |
| 886 | + roSlice := x.ro or x.elemRo or ofConst(x); (* x.ro: another module's, or a const parameter's *) | |
| 895 | 887 | end; |
| 896 | 888 | if t^.form = Sym.fPtr then try needSystem(x.pos, "a slice of a pointer"); end; |
| 897 | 889 | try value(hi); |
| @@ -2554,7 +2546,7 @@ | ||
| 2554 | 2546 | try value(x); |
| 2555 | 2547 | s := Gen.allocTemp(16, 8); |
| 2556 | 2548 | Gen.errorText(s); |
| 2557 | - if strict then tempItem(x, Sym.tConstBytes, s); else tempItem(x, Sym.tBytes, s); end; (* the message is constant *) | |
| 2549 | + tempItem(x, Sym.tConstBytes, s); (* the message is constant *) | |
| 2558 | 2550 | return nil; |
| 2559 | 2551 | end; |
| 2560 | 2552 |
| @@ -1103,45 +1103,34 @@ | ||
| 1103 | 1103 | end; |
| 1104 | 1104 | |
| 1105 | 1105 | (* CAS(v, old, new), XCHG(v, x) or XADD(v, x) (report 6.8): v is a |
| 1106 | - variable, whose address goes on the stack, as ADR's would. A pointer | |
| 1107 | - that isn't a variable, ADR(v) say, is the form before report | |
| 1108 | - 2026-10.37, still taken: what it points at is the variable. *) | |
| 1106 | + variable, whose address goes on the stack, as ADR's would. Before | |
| 1107 | + report 2026-10.37 they took a pointer to it, ADR(v): the error says | |
| 1108 | + so. *) | |
| 1109 | 1109 | proc atomic(var x: TItem; which: INT): ERROR; |
| 1110 | 1110 | var p, a: TItem; t: PType; i, n: INT; |
| 1111 | 1111 | begin |
| 1112 | 1112 | try expression(p, nil); |
| 1113 | - if (p.mode = Item.mVar) and p.isVar then | |
| 1114 | - t := p.typ; | |
| 1115 | - if not atomicType(t, which) then | |
| 1116 | - if (t^.form = Sym.fPtr) and atomicType(t^.base, which) then | |
| 1117 | - return Scan.markHelp(p.pos, say1("{} works on an INT or a UINT variable, not a pointer", atomicName(which)), | |
| 1118 | - say1("for what the pointer points at, write {}^", Diag.source(p.pos))); | |
| 1119 | - elsif which = Sym.bXadd then | |
| 1120 | - return Scan.markAt(p.pos, say1("expected an INT or a UINT variable, found {}", Item.what(p))); | |
| 1121 | - end; | |
| 1122 | - return Scan.markAt(p.pos, say1("expected an INT, a UINT or a pointer variable, found {}", Item.what(p))); | |
| 1123 | - end; | |
| 1124 | - try Item.notReadOnly(p); | |
| 1125 | - if p.odd then return Scan.markAt(p.pos, "a field of a packed record has no address"); end; | |
| 1126 | - if p.view then return Item.noAddress(p, "an atomic can't take a view"); end; | |
| 1127 | - try Item.address(p); | |
| 1128 | - else | |
| 1129 | - if p.typ^.form # Sym.fPtr then | |
| 1130 | - return Scan.markAt(p.pos, say1("expected a variable, found {}", Item.what(p))); | |
| 1131 | - end; | |
| 1132 | - if Item.strict then | |
| 1113 | + if (p.mode # Item.mVar) or not p.isVar then | |
| 1114 | + if p.typ^.form = Sym.fPtr then | |
| 1133 | 1115 | return Scan.markHelp(p.pos, say1("{} takes a variable, not a pointer to it", atomicName(which)), |
| 1134 | 1116 | "give it the variable itself: XADD(n, 1), or XADD(p^, 1) through a pointer"); |
| 1135 | 1117 | end; |
| 1136 | - t := p.typ^.base; | |
| 1137 | - if not atomicType(t, which) then | |
| 1138 | - if which = Sym.bXadd then | |
| 1139 | - return Scan.markAt(p.pos, say1("expected a pointer to an INT or a UINT, found {}", Sym.typeName(p.typ))); | |
| 1140 | - end; | |
| 1141 | - return Scan.markAt(p.pos, say1("expected a pointer to an INT, a UINT or a pointer, found {}", Sym.typeName(p.typ))); | |
| 1118 | + return Scan.markAt(p.pos, say1("expected a variable, found {}", Item.what(p))); | |
| 1119 | + end; | |
| 1120 | + t := p.typ; | |
| 1121 | + if not atomicType(t, which) then | |
| 1122 | + if (t^.form = Sym.fPtr) and atomicType(t^.base, which) then | |
| 1123 | + return Scan.markHelp(p.pos, say1("{} works on an INT or a UINT variable, not a pointer", atomicName(which)), | |
| 1124 | + say1("for what the pointer points at, write {}^", Diag.source(p.pos))); | |
| 1125 | + elsif which = Sym.bXadd then | |
| 1126 | + return Scan.markAt(p.pos, say1("expected an INT or a UINT variable, found {}", Item.what(p))); | |
| 1142 | 1127 | end; |
| 1143 | - try Item.value(p); | |
| 1128 | + return Scan.markAt(p.pos, say1("expected an INT, a UINT or a pointer variable, found {}", Item.what(p))); | |
| 1144 | 1129 | end; |
| 1130 | + try Item.notReadOnly(p); | |
| 1131 | + if p.odd then return Scan.markAt(p.pos, "a field of a packed record has no address"); end; | |
| 1132 | + if p.view then return Item.noAddress(p, "an atomic can't take a view"); end; | |
| 1133 | + try Item.address(p); | |
| 1145 | 1134 | if which = Sym.bCas then n := 2; else n := 1; end; |
| 1146 | 1135 | for i := 1 to n do |
| 1147 | 1136 | try expect(Scan.sComma); |
| @@ -1265,7 +1254,7 @@ | ||
| 1265 | 1254 | var which, n, start: INT; y: TItem; t: PType; f: PObj; at: Diag.Pos; |
| 1266 | 1255 | begin |
| 1267 | 1256 | which := INT(x.obj^.val); |
| 1268 | - if Item.strict and (x.obj^.home # Sym.system) | |
| 1257 | + if (x.obj^.home # Sym.system) | |
| 1269 | 1258 | and ((which = Sym.bAdr) or (which = Sym.bPtr) or (which = Sym.bSyscall) or (which = Sym.bArgv)) then |
| 1270 | 1259 | return Scan.markHelp(x.pos, say2("{} is SYSTEM's, and written SYSTEM.{}", nameOf(x.obj^.name), nameOf(x.obj^.name)), |
| 1271 | 1260 | "say import SYSTEM after the module's imports, and write the name after SYSTEM."); |
| @@ -3551,7 +3540,7 @@ | ||
| 3551 | 3540 | end; |
| 3552 | 3541 | p^.fwd := false; |
| 3553 | 3542 | if Scan.tok = Scan.sCode then |
| 3554 | - try Item.needSystem(Scan.tokPos(), "a code procedure"); | |
| 3543 | + _ := Item.needSystem(Scan.tokPos(), "a code procedure"); (* said, and the declaration read on *) | |
| 3555 | 3544 | Scan.next; |
| 3556 | 3545 | p^.isCode := true; |
| 3557 | 3546 | try codeBody(p, sig, at); |
| @@ -3576,7 +3565,7 @@ | ||
| 3576 | 3565 | proc externDecl: ERROR; |
| 3577 | 3566 | var n: INT; exp: BOOL; o, q: PObj; t: PType; at: Diag.Pos; |
| 3578 | 3567 | begin |
| 3579 | - try Item.needSystem(Scan.tokPos(), "extern"); | |
| 3568 | + _ := Item.needSystem(Scan.tokPos(), "extern"); (* said, and the declaration read on *) | |
| 3580 | 3569 | Scan.next; |
| 3581 | 3570 | Sym.curModule^.usesC := true; |
| 3582 | 3571 | if Scan.tok = Scan.sProc then |
| @@ -3789,7 +3778,7 @@ | ||
| 3789 | 3778 | return Scan.mark(say1("expected {}, found an array literal", Sym.typeName(t))); |
| 3790 | 3779 | end; |
| 3791 | 3780 | try expression(e, t); |
| 3792 | - if Item.strict and (t^.form = Sym.fSlice) and not t^.rdonly then | |
| 3781 | + if (t^.form = Sym.fSlice) and not t^.rdonly then | |
| 3793 | 3782 | return Scan.markHelp(e.pos, say1("a constant's slice is a []const, not {}", Sym.typeName(t)), |
| 3794 | 3783 | "a constant can't be changed: declare the slice []const"); |
| 3795 | 3784 | end; |
| @@ -4444,7 +4433,7 @@ | ||
| 4444 | 4433 | if (Scan.tok = Scan.sIdent) and (Scan.id = nameStatic) then |
| 4445 | 4434 | m^.linkStatic := true; |
| 4446 | 4435 | elsif Scan.tok = Scan.sString then |
| 4447 | - try Item.needSystem(Scan.tokPos(), "a link of a library"); | |
| 4436 | + _ := Item.needSystem(Scan.tokPos(), "a link of a library"); (* said, and the declaration read on *) | |
| 4448 | 4437 | NEW(lib, Heap.heap); |
| 4449 | 4438 | lib^.name := internName(Scan.strBytes()); |
| 4450 | 4439 | lib^.next := m^.libs; |
| @@ -4459,7 +4448,7 @@ | ||
| 4459 | 4448 | (* check off;: the module's index and slice checks left out; neither |
| 4460 | 4449 | word is reserved *) |
| 4461 | 4450 | if (Scan.tok = Scan.sIdent) and (Scan.id = nameCheck) then |
| 4462 | - try Item.needSystem(Scan.tokPos(), "check off"); | |
| 4451 | + _ := Item.needSystem(Scan.tokPos(), "check off"); (* said, and the declaration read on *) | |
| 4463 | 4452 | Scan.next; |
| 4464 | 4453 | if (Scan.tok # Scan.sIdent) or (Scan.id # nameOff) then return nil, expected("\"off\""); end; |
| 4465 | 4454 | Scan.next; |
| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | Leaves out: the work itself; the other units compile, link and |
| 30 | 30 | write, and this only reads the command line and runs them in order. *) |
| 31 | 31 | module Raz; |
| 32 | -import Sys, Out, Version, Files, Fmt, Diag, Scan, Sym, Chunk, X64, Gen, Item, Parse, Link, Elf; | |
| 32 | +import Sys, Out, Version, Files, Fmt, Diag, Scan, Sym, Chunk, X64, Gen, Parse, Link, Elf; | |
| 33 | 33 | import SYSTEM; |
| 34 | 34 | |
| 35 | 35 | const |
| @@ -259,9 +259,6 @@ | ||
| 259 | 259 | bare := false; |
| 260 | 260 | listing := false; |
| 261 | 261 | libcSaid := false; |
| 262 | - (* until v0.24.0, RAZ_STRICT=1 is -strict for every compile, so that a | |
| 263 | - whole test run can be made strict *) | |
| 264 | - if Sys.env("RAZ_STRICT") = "1" then Item.setStrict(true); end; | |
| 265 | 262 | run := (ARGC() >= 2) and (Files.arg(1) = "run"); |
| 266 | 263 | if run then i := 2; else i := 1; end; |
| 267 | 264 | while i < ARGC() do |
| @@ -275,9 +272,6 @@ | ||
| 275 | 272 | outPath := Files.arg(i); |
| 276 | 273 | elsif s = "-Werror" then |
| 277 | 274 | Diag.setWerror(true); |
| 278 | - elsif s = "-strict" then | |
| 279 | - (* until v0.24.0: report 2026-10.37 held whole, its old forms refused *) | |
| 280 | - Item.setStrict(true); | |
| 281 | 275 | elsif s = "-S" then |
| 282 | 276 | listing := true; |
| 283 | 277 | X64.setListing(true); |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/AtomicPointer.raz:9:15: error: XADD takes a variable, not a pointer to it | |
| 2 | + 9 | _ := XADD(SYSTEM.ADR(n), 1); | |
| 3 | + | ^^^^^^^^^^^^^ | |
| 4 | +help: give it the variable itself: XADD(n, 1), or XADD(p^, 1) through a pointer | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/ConstArrayToSlice.raz:9:10: error: can't use [3]INT as []INT | |
| 2 | + 9 | s := Primes; | |
| 3 | + | ^^^^^^ | |
| 4 | +help: Primes is only read: a slice of it is a []const | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/MsgToSlice.raz:9:10: error: can't use []const U8 as []U8 | |
| 2 | + 9 | s := MSG(Oops); | |
| 3 | + | ^^^^^^^^^ | |
| 4 | +help: its elements are only read, and a []T could write them | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/StringToSlice.raz:8:10: error: a string is a []const U8, not []U8 | |
| 2 | + 8 | s := "abc"; | |
| 3 | + | ^^^^^ | |
| 4 | +help: its bytes are constant: take a []const U8 where they are only read, or copy them | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/SystemArith.raz:6:12: error: a pointer's arithmetic needs import SYSTEM | |
| 2 | + 6 | return p + 1; | |
| 3 | + | ^^^^^ | |
| 4 | +help: it reaches memory other than through a variable: say import SYSTEM after the module's imports | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/SystemBareAdr.raz:9:10: error: ADR is SYSTEM's, and written SYSTEM.ADR | |
| 2 | + 9 | p := ADR(n); | |
| 3 | + | ^^^ | |
| 4 | +help: say import SYSTEM after the module's imports, and write the name after SYSTEM. | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/SystemCheckOff.raz:3:1: error: check off needs import SYSTEM | |
| 2 | + 3 | check off; | |
| 3 | + | ^^^^^ | |
| 4 | +help: it reaches memory other than through a variable: say import SYSTEM after the module's imports | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/SystemConvert.raz:7:15: error: a conversion to ^INT needs import SYSTEM | |
| 2 | + 7 | p := ^INT(4096); | |
| 3 | + | ^^^^ | |
| 4 | +help: it reaches memory other than through a variable: say import SYSTEM after the module's imports | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/SystemExtern.raz:4:1: error: extern needs import SYSTEM | |
| 2 | + 4 | extern proc getpid(): I32; | |
| 3 | + | ^^^^^^ | |
| 4 | +help: it reaches memory other than through a variable: say import SYSTEM after the module's imports | |
| 5 | +raz: 1 error |