raz / commit 4402a682

commit
4402a6820a5a40f7d98b7abe9478b792dd1a2f38
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
264716cb
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.

patch · log

26 files changed, +236 -107

CLAUDE.md modified +14 -15

@@ -95,8 +95,9 @@
9595 mode. Every old form is still taken: a literal into a `[]U8`, the bare
9696 built-ins, what `SYSTEM` fences without it, an atomic given `ADR(x)`.
9797 `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.
100101 v0.22.0, report 2026-10.36, before it, is the twelfth thaw, what `PROPOSALS.md`
101102 collated: `MIN`, `MAX`, `ABS`, `CLZ`, `CTZ`, `POPCOUNT`, `INT(b)`,
102103 `OFFSET`, `SIZE(T.f)`, `BYTES` and `FILL`; a qualified case in an arm,
@@ -386,18 +387,15 @@
386387 - `CAS(v, old, new)`, `XCHG(v, x)` and `XADD(v, x)` (report 2026-10.37)
387388 take a variable, whose address is pushed as `ADR`'s is (`atomic`); a
388389 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^`.
395393 - `import SYSTEM` (report 2026-10.37) binds to `Sym.system`, no file,
396394 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.
401399 - `[]const T` (report 2026-10.37) is a slice type with `rdonly` set: not
402400 the same as `[]T`, which goes into it with no code (`coerce`), never
403401 back (help says why). An element read through one has the item's
@@ -406,9 +404,10 @@
406404 and `FILL` refuse one as their destination (`destSlice`); a slice of
407405 one, or of an array read through one or of another module's array,
408406 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`.
412411 - `ROL(x, n)` and `ROR(x, n)` (report 2026-10.35) are done at `x`'s
413412 own width, `rol al, cl` for a `U8`, with no mask of the count: x86
414413 takes it modulo 32 or 64, and a byte's or a word's rotation goes

PLAN.md (history) modified +3 -1

@@ -92,7 +92,9 @@
9292 and v0.23.0; 35 pages. No rewriting tool, by the owner's word:
9393 v0.24.0's errors point at each place to mend.
9494 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/`,
9698 `examples/` and the tests mended where the old forms, made errors,
9799 are found (`ADR` at a parameter only dereferenced becomes `var` or
98100 `const`; `SYSTEM.` where an address is kept); the programs in `~/r`

conform/err/AtomicPointer.raz (history) added +12 -0

@@ -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.

conform/err/ConstArrayToSlice.raz (history) added +13 -0

@@ -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.

conform/err/MsgToSlice.raz (history) added +13 -0

@@ -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.

conform/err/StringToSlice.raz (history) added +12 -0

@@ -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.

conform/err/SystemArith.raz (history) added +14 -0

@@ -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.

conform/err/SystemBareAdr.raz (history) added +13 -0

@@ -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.

conform/err/SystemCheckOff.raz (history) added +9 -0

@@ -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.

conform/err/SystemConvert.raz (history) added +11 -0

@@ -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.

conform/err/SystemExtern.raz (history) added +11 -0

@@ -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.

doc/compiler.md (history) modified +23 -23

@@ -1,6 +1,6 @@
11 # Reading the raz compiler
22
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
44 budget is 14,000). It is its own compiler: a release of it, the one
55 `BOOT` names, builds `src/`, and `make fixpoint` checks that what it
66 makes makes itself again, byte for byte. Each release was built by the
@@ -16,17 +16,17 @@
1616
1717 | File | Lines | Code | What |
1818 |---|---|---|---|
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 |
3030
3131 Every file opens with a comment that says what it is, what it depends
3232 on and what it leaves out. Read those first; they are the map.
@@ -1885,17 +1885,18 @@
18851885 which its type's fingerprint has.
18861886
18871887 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
18911890 slicing, pointer and procedure conversions, views and `BYTES` that make
18921891 or change an address (`Sym.isPlain`, the item's `viewOver`, checked in
18931892 `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.
18991900
19001901 `import SYSTEM` (report 2026-10.37) finds no file: the import binds the
19011902 name to `Sym.system`, a module made once in `Sym`'s body whose scope
@@ -1904,8 +1905,7 @@
19041905 export and `builtin` compiles it as `ADR`. It is marked used at the
19051906 import, since a module may import it only for `extern` or `link`. An
19061907 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.
19091909
19101910 `importModule` finds a module's file, trying the target's names first,
19111911 and compiles it if it isn't yet. A module found in an `-I` or
@@ -1990,7 +1990,7 @@
19901990 does: `atomic` pushes its address, as `ADR` would, and `Gen.atomic`
19911991 works through it as before, so the code is the same as for
19921992 `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
19941994 address is taken, `chooseRegs` keeps a local named in one in memory,
19951995 as it does one named in `ADR`.
19961996

doc/raz.md (history) modified +1 -1

@@ -76,7 +76,7 @@
7676 10 says what is left undefined outside such modules. It breaks a
7777 program that gives an atomic a pointer, writes through a string or a
7878 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.
8080
8181 The language is frozen, softly, from this version on: it changes only
8282 to mend a defect, and its library grows only by what breaks no program

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

@@ -268,15 +268,15 @@
268268 And `CAS`, `XCHG` and `XADD` take the variable they work on, as `INC`
269269 does, not a pointer to it (section 6.8): `XADD(count, 1)`,
270270 `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.
272272 And `[]const T`, a slice whose elements can't be written through it
273273 (section 5.3): a `[]T` or an array goes where one is wanted, never
274274 the other way. A string literal and a slice of a constant are
275275 `[]const`, as `MSG` and a slice of a `const` parameter's array are,
276276 so writing them is an error, not undefined; another module's exported
277277 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.
280280 And `import SYSTEM` (section 3): a module the language gives, with no
281281 file, that a module imports, by that name only, to reach memory other
282282 than through its variables: `SYSTEM.ADR`, `SYSTEM.PTR`,
@@ -287,4 +287,4 @@
287287 and 9). Section 10 says what is left undefined outside such modules,
288288 and 7.6 that a race on a pointer, a slice or a variant is undefined.
289289 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.

src/Item.raz (history) modified +12 -20

@@ -84,8 +84,6 @@
8484 procedure is compiled again, the variable in memory *)
8585 checks*: BOOL; (* the module's index and slice checks are made: it
8686 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 *)
8987 result: ^Sym.Type; (* the result of the procedure being compiled, or nil *)
9088 passing: ^Sym.Obj; (* the parameter the argument at passingAt goes to *)
9189 passingAt: Diag.Pos;
@@ -100,11 +98,6 @@
10098 checks := yes;
10199 end;
102100
103-proc setStrict*(yes: BOOL);
104-begin
105- strict := yes;
106-end;
107-
108101 (* The comparison that holds when op doesn't *)
109102 proc negated(op: Scan.Sym): Scan.Sym;
110103 begin
@@ -138,12 +131,11 @@
138131 return Diag.say(f, [Fmt.str(a)]);
139132 end;
140133
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) *)
144136 proc needSystem*(pos: Diag.Pos; what: []const U8): ERROR;
145137 begin
146- if strict and not Sym.curModule^.system then
138+ if not Sym.curModule^.system then
147139 return Scan.markHelp(pos, say1("{} needs import SYSTEM", what),
148140 "it reaches memory other than through a variable: say import SYSTEM after the module's imports");
149141 end;
@@ -641,7 +633,7 @@
641633 if x.mode = mCond then try value(x); end;
642634 s := x.typ;
643635 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
645637 return mismatchHelp(x, say1("a string is a []const U8, not {}", Sym.typeName(t)),
646638 "its bytes are constant: take a []const U8 where they are only read, or copy them");
647639 end;
@@ -683,10 +675,10 @@
683675 return mismatchHelp(x, say2("can't use {} as {}", Sym.typeName(s), Sym.typeName(t)),
684676 "its elements are only read, and a []T could write them");
685677 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
690682 return mismatchHelp(x, say2("can't use {} as {}", Sym.typeName(s), Sym.typeName(t)),
691683 say1("{} is only read: a slice of it is a []const", Diag.source(x.pos)));
692684 end;
@@ -695,7 +687,7 @@
695687 [Fmt.str(Diag.source(x.pos)), Fmt.str(Scan.nameOf(x.obj^.home^.name))]),
696688 say1("it may be read as a {}", Sym.typeName(constOf(t))));
697689 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;
699691 if x.vol then return Scan.markAt(x.pos, "can't make a slice through a volatile pointer"); end;
700692 if x.odd then return Scan.markAt(x.pos, "can't make a slice of a field of a packed record"); end;
701693 if x.view then return noAddress(x, "can't make a slice of a view"); end;
@@ -805,7 +797,7 @@
805797 begin
806798 nilTest(x);
807799 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);
809801 end;
810802 if (x.typ^.form = Sym.fPtr) and (x.typ^.base^.form = Sym.fArray) then
811803 return Scan.markAt(x.pos, "a pointer to an array is indexed as p^[i]");
@@ -891,7 +883,7 @@
891883 []const, is a []const; of a const parameter's, a slice to read *)
892884 roSlice := (t^.form = Sym.fSlice) and t^.rdonly;
893885 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 *)
895887 end;
896888 if t^.form = Sym.fPtr then try needSystem(x.pos, "a slice of a pointer"); end;
897889 try value(hi);
@@ -2554,7 +2546,7 @@
25542546 try value(x);
25552547 s := Gen.allocTemp(16, 8);
25562548 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 *)
25582550 return nil;
25592551 end;
25602552

src/Parse.raz (history) modified +25 -36

@@ -1103,45 +1103,34 @@
11031103 end;
11041104
11051105 (* 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. *)
11091109 proc atomic(var x: TItem; which: INT): ERROR;
11101110 var p, a: TItem; t: PType; i, n: INT;
11111111 begin
11121112 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
11331115 return Scan.markHelp(p.pos, say1("{} takes a variable, not a pointer to it", atomicName(which)),
11341116 "give it the variable itself: XADD(n, 1), or XADD(p^, 1) through a pointer");
11351117 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)));
11421127 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)));
11441129 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);
11451134 if which = Sym.bCas then n := 2; else n := 1; end;
11461135 for i := 1 to n do
11471136 try expect(Scan.sComma);
@@ -1265,7 +1254,7 @@
12651254 var which, n, start: INT; y: TItem; t: PType; f: PObj; at: Diag.Pos;
12661255 begin
12671256 which := INT(x.obj^.val);
1268- if Item.strict and (x.obj^.home # Sym.system)
1257+ if (x.obj^.home # Sym.system)
12691258 and ((which = Sym.bAdr) or (which = Sym.bPtr) or (which = Sym.bSyscall) or (which = Sym.bArgv)) then
12701259 return Scan.markHelp(x.pos, say2("{} is SYSTEM's, and written SYSTEM.{}", nameOf(x.obj^.name), nameOf(x.obj^.name)),
12711260 "say import SYSTEM after the module's imports, and write the name after SYSTEM.");
@@ -3551,7 +3540,7 @@
35513540 end;
35523541 p^.fwd := false;
35533542 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 *)
35553544 Scan.next;
35563545 p^.isCode := true;
35573546 try codeBody(p, sig, at);
@@ -3576,7 +3565,7 @@
35763565 proc externDecl: ERROR;
35773566 var n: INT; exp: BOOL; o, q: PObj; t: PType; at: Diag.Pos;
35783567 begin
3579- try Item.needSystem(Scan.tokPos(), "extern");
3568+ _ := Item.needSystem(Scan.tokPos(), "extern"); (* said, and the declaration read on *)
35803569 Scan.next;
35813570 Sym.curModule^.usesC := true;
35823571 if Scan.tok = Scan.sProc then
@@ -3789,7 +3778,7 @@
37893778 return Scan.mark(say1("expected {}, found an array literal", Sym.typeName(t)));
37903779 end;
37913780 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
37933782 return Scan.markHelp(e.pos, say1("a constant's slice is a []const, not {}", Sym.typeName(t)),
37943783 "a constant can't be changed: declare the slice []const");
37953784 end;
@@ -4444,7 +4433,7 @@
44444433 if (Scan.tok = Scan.sIdent) and (Scan.id = nameStatic) then
44454434 m^.linkStatic := true;
44464435 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 *)
44484437 NEW(lib, Heap.heap);
44494438 lib^.name := internName(Scan.strBytes());
44504439 lib^.next := m^.libs;
@@ -4459,7 +4448,7 @@
44594448 (* check off;: the module's index and slice checks left out; neither
44604449 word is reserved *)
44614450 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 *)
44634452 Scan.next;
44644453 if (Scan.tok # Scan.sIdent) or (Scan.id # nameOff) then return nil, expected("\"off\""); end;
44654454 Scan.next;

src/Raz.raz (history) modified +1 -7

@@ -29,7 +29,7 @@
2929 Leaves out: the work itself; the other units compile, link and
3030 write, and this only reads the command line and runs them in order. *)
3131 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;
3333 import SYSTEM;
3434
3535 const
@@ -259,9 +259,6 @@
259259 bare := false;
260260 listing := false;
261261 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;
265262 run := (ARGC() >= 2) and (Files.arg(1) = "run");
266263 if run then i := 2; else i := 1; end;
267264 while i < ARGC() do
@@ -275,9 +272,6 @@
275272 outPath := Files.arg(i);
276273 elsif s = "-Werror" then
277274 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);
281275 elsif s = "-S" then
282276 listing := true;
283277 X64.setListing(true);

test/msg/AtomicPointer.err (history) added +5 -0

@@ -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

test/msg/ConstArrayToSlice.err (history) added +5 -0

@@ -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

test/msg/MsgToSlice.err (history) added +5 -0

@@ -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

test/msg/StringToSlice.err (history) added +5 -0

@@ -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

test/msg/SystemArith.err (history) added +5 -0

@@ -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

test/msg/SystemBareAdr.err (history) added +5 -0

@@ -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

test/msg/SystemCheckOff.err (history) added +5 -0

@@ -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

test/msg/SystemConvert.err (history) added +5 -0

@@ -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

test/msg/SystemExtern.err (history) added +5 -0

@@ -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