raz / commit cb2bb189

commit
cb2bb1899bc9b216e63d68df2ae3e7c456ee1884
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
c027dc28
diag.pas: one place for messages, with the source underlined

Positions are a file and a byte range; line/col worked out only when
printing. Colour on a tty unless NO_COLOR. Counts, summary, -Werror.
test/err compares the whole message now.

patch · log

41 files changed, +381 -81

Makefile (history) modified +1 -1

@@ -16,7 +16,7 @@
1616 FORCE:
1717
1818 units: src/*.pas | build
19- for u in scan sym x64 link elf; do $(FPC) $(FPCFLAGS) src/$$u.pas || exit 1; done
19+ for u in diag scan sym x64 link elf; do $(FPC) $(FPCFLAGS) src/$$u.pas || exit 1; done
2020
2121 # tests of the parts below the parser, built from test/
2222 tests: units

PLAN.md (history) modified +4 -4

@@ -191,7 +191,7 @@
191191 T.raz:3:5: note: x is declared here
192192 3 | var x: I64;
193193 | ^
194-T.raz: 1 error
194+raz: 1 error
195195 ```
196196
197197 How messages are worded, for every step that writes one: lowercase,
@@ -211,9 +211,9 @@
211211 - [x] 19. The report first, for review before any code: messages,
212212 warnings and `-Werror` in section 10, run-time messages in
213213 sections 6.5 and 10, report version `2026-10.1`. *main*
214-- [ ] 20. `src/diag.pas`, the one place messages are made: a position
215- (file, line, first and last column) and a message built in
216- pieces, past shortstring's 255 characters; the source excerpt
214+- [x] 20. `src/diag.pas`, the one place messages are made: a position
215+ (a file and a stretch of bytes, its line and columns worked out
216+ only for a message); the source excerpt
217217 and its underline, colour, notes and help; counting errors and
218218 warnings, the summary, `-Werror`, the exit status. `Mark` and
219219 `Fatal` move there. `test/err` and `test/pretty` keep working:

README.md (history) modified +4 -3

@@ -68,8 +68,8 @@
6868
6969 ## Using it
7070
71- raz [-I dir]... [-o file] Main.raz
72- raz run [-I dir]... Main.raz [arg]...
71+ raz [-I dir]... [-o file] [-Werror] Main.raz
72+ raz run [-I dir]... [-Werror] Main.raz [arg]...
7373 raz --version
7474
7575 `raz Main.raz` compiles module `Main` and every module it imports, and
@@ -77,7 +77,8 @@
7777 in the main module's directory, then in each `-I` directory, then in
7878 `lib`. A module whose code depends on the system comes in one file per
7979 target, `Name.linux-x86_64.raz` before `Name.raz`; the compiler checks
80-that all of them export the same things.
80+that all of them export the same things. `-Werror` makes warnings
81+errors.
8182
8283 `raz run Main.raz a b` compiles the same way, then runs the program
8384 with the arguments `a b`, writing no file: its output and exit status

doc/compiler.md (history) modified +19 -6

@@ -1,6 +1,6 @@
11 # Reading the raz compiler
22
3-The compiler is eight files of Free Pascal, under 5,000 lines of code.
3+The compiler is nine files of Free Pascal, under 6,000 lines of code.
44 This guide walks through them in the order they are best read: from the
55 characters of a source file to the bytes of an executable. It assumes
66 you know the language from `doc/raz.md`, and enough x86-64 to read a
@@ -8,14 +8,15 @@
88
99 | File | Lines | Code | What |
1010 |---|---|---|---|
11-| `src/scan.pas` | 548 | 471 | Symbols, literals, comments, error messages |
11+| `src/diag.pas` | 227 | 162 | Messages: positions, source excerpts, colour, counts |
12+| `src/scan.pas` | 535 | 459 | Symbols, literals, comments, positions |
1213 | `src/sym.pas` | 508 | 422 | Types, objects, scopes, layout |
1314 | `src/x64.pas` | 680 | 546 | Code buffer, chunks, fixups, line notes, instruction encoder |
1415 | `src/gen.pas` | 1,414 | 1,240 | Items: loading, storing, copying, frames, calls |
1516 | `src/parse.pas` | 1,816 | 1,685 | Declarations, statements, expressions, built-ins |
1617 | `src/link.pas` | 131 | 95 | Tree shaking, layout, patching |
1718 | `src/elf.pas` | 425 | 351 | Static and dynamic ELF, symbol table, line numbers |
18-| `src/raz.pas` | 216 | 169 | The command line, the entry points |
19+| `src/raz.pas` | 219 | 172 | The command line, the entry points |
1920
2021 Every file opens with a comment that says what it is, what it depends
2122 on and what it leaves out. Read those first; they are the map.
@@ -111,6 +112,18 @@
111112 is not fast code. It is code whose every instruction you can account
112113 for, which is the point.
113114
115+## diag.pas: messages
116+
117+Every message the compiler prints is made here. A position, `TPos`, is
118+a file and a stretch of bytes in it; `Error`, `Warning` and `Note` show
119+it as `file:line:column`, then the line of source with the stretch
120+underlined, and `Help` adds a line of advice. The line and column are
121+worked out only when a message is printed (`Locate`, `Chars`), so
122+positions cost nothing while compiling. `AddFile` keeps every source
123+file the scanner opens, so a note can show a line of any of them.
124+`Finish` prints the count of errors and warnings and stops if there
125+were errors; `Fatal` is for errors with no place in the source.
126+
114127 ## scan.pas: the scanner
115128
116129 The scanner turns bytes into symbols (`TSym`). The current symbol is in
@@ -132,9 +145,9 @@
132145 Source is UTF-8, checked by `Utf8` wherever a byte above 127 appears:
133146 in strings, characters and comments. Anywhere else it is an error.
134147
135-Errors go through `Mark`, which prints `file:line:column` (the column
136-counted in characters, by `Column`) and stops. There is no recovery:
137-the first error ends the compilation. `SaveScan` and `RestoreScan` keep
148+`TokPos` is the position of the current symbol. Errors go through
149+`Mark`, which reports one there (`diag.Error`) and stops. There is no
150+recovery: the first error ends the compilation. `SaveScan` and `RestoreScan` keep
138151 the scanner's state while an imported module is compiled.
139152
140153 ## sym.pas: types, objects and scopes

src/diag.pas added +227 -0

@@ -0,0 +1,227 @@
1+{ diag.pas: messages.
2+
3+ The one place the compiler's messages are made. A message is an
4+ error or a warning at a position, which it shows as the file, line
5+ and column, then the line of source with the position underlined;
6+ notes, each at a position of its own, and help, a line of advice,
7+ may follow it. Colour is used when standard error is a terminal and
8+ NO_COLOR isn't set. diag keeps every source file it is given, so
9+ that a note can show a line of a module compiled earlier.
10+
11+ Depends on: BaseUnix and termio, to write and to ask about the
12+ terminal.
13+ Leaves out: wording. The callers say what is wrong; a message is at
14+ most 255 characters, which every message so far keeps well within. }
15+
16+unit diag;
17+
18+{$mode objfpc}{$H-}
19+
20+interface
21+
22+type
23+ { A stretch of a source file: bytes a up to but not including b.
24+ a = b marks the place between two characters. }
25+ TPos = record
26+ f, a, b: longint;
27+ end;
28+
29+const
30+ MaxErrors = 20;
31+
32+var
33+ errors, warnings: longint;
34+ werror: boolean; { -Werror: a warning counts as an error }
35+
36+function AddFile(const path: shortstring; buf: PChar; len: longint): longint;
37+function PathOf(f: longint): shortstring;
38+function LineOf(const p: TPos): longint;
39+procedure Error(const p: TPos; const msg: shortstring);
40+procedure Warning(const p: TPos; const msg: shortstring);
41+procedure Note(const p: TPos; const msg: shortstring);
42+procedure Help(const msg: shortstring);
43+procedure Fatal(const msg: shortstring);
44+procedure Finish;
45+
46+implementation
47+
48+uses BaseUnix, termio;
49+
50+type
51+ TFile = record
52+ path: shortstring;
53+ buf: PChar;
54+ len: longint;
55+ end;
56+
57+var
58+ files: ^TFile; { numFiles of them, in room for cap }
59+ numFiles, cap: longint;
60+ colour, colourKnown: boolean;
61+
62+function AddFile(const path: shortstring; buf: PChar; len: longint): longint;
63+begin
64+ if numFiles = cap then begin
65+ cap := 2 * cap + 8;
66+ ReallocMem(files, cap * SizeOf(TFile));
67+ end;
68+ files[numFiles].path := path;
69+ files[numFiles].buf := buf;
70+ files[numFiles].len := len;
71+ AddFile := numFiles;
72+ inc(numFiles);
73+end;
74+
75+function PathOf(f: longint): shortstring;
76+begin
77+ PathOf := files[f].path;
78+end;
79+
80+{ Writing }
81+
82+const
83+ Bold = #27'[1m'; Red = #27'[1;31m'; Yellow = #27'[1;33m';
84+ Cyan = #27'[1;36m'; Green = #27'[1;32m'; Blue = #27'[1;34m';
85+ Plain = #27'[0m';
86+
87+{ Whether NO_COLOR is set, to anything }
88+function NoColour: boolean;
89+var e: PPChar;
90+begin
91+ e := envp;
92+ while (e^ <> nil) and (CompareByte(e^^, PChar('NO_COLOR=')^, 9) <> 0) do inc(e);
93+ NoColour := e^ <> nil;
94+end;
95+
96+{ s in colour c, when colour is on }
97+function Paint(const c, s: shortstring): shortstring;
98+begin
99+ if not colourKnown then begin
100+ colour := (IsATTY(2) = 1) and not NoColour;
101+ colourKnown := true;
102+ end;
103+ if colour then Paint := c + s + Plain else Paint := s;
104+end;
105+
106+function IntStr(n: longint): shortstring;
107+var s: shortstring;
108+begin
109+ Str(n, s);
110+ IntStr := s;
111+end;
112+
113+{ Positions }
114+
115+{ The line of p, and the byte where it starts. Lines are counted from
116+ the start of the file, which is slow only next to compiling it. }
117+procedure Locate(const p: TPos; out line, start: longint);
118+var i: longint; buf: PChar;
119+begin
120+ buf := files[p.f].buf;
121+ line := 1; start := 0;
122+ for i := 0 to p.a - 1 do
123+ if buf[i] = #10 then begin inc(line); start := i + 1 end;
124+end;
125+
126+function LineOf(const p: TPos): longint;
127+var line, start: longint;
128+begin
129+ Locate(p, line, start);
130+ LineOf := line;
131+end;
132+
133+{ Characters from byte i to byte j of buf: every byte but a UTF-8
134+ continuation byte. }
135+function Chars(buf: PChar; i, j: longint): longint;
136+var n: longint;
137+begin
138+ n := 0;
139+ for i := i to j - 1 do
140+ if (byte(buf[i]) and $C0) <> $80 then inc(n);
141+ Chars := n;
142+end;
143+
144+{ "file:line:col: kind: msg", then the line with p underlined. A tab
145+ before p is copied into the underline, so that the two line up
146+ whatever the terminal makes of tabs. }
147+procedure Show(const p: TPos; const kind, kindColour, msg: shortstring);
148+var line, start, stop, i, n: longint; buf: PChar; num, gutter: shortstring;
149+begin
150+ Locate(p, line, start);
151+ buf := files[p.f].buf;
152+ writeln(StdErr, Paint(Bold, files[p.f].path + ':' + IntStr(line) + ':'
153+ + IntStr(Chars(buf, start, p.a) + 1) + ':'), ' ', Paint(kindColour, kind + ':'),
154+ ' ', Paint(Bold, msg));
155+ stop := start;
156+ while (stop < files[p.f].len) and (buf[stop] <> #10) do inc(stop);
157+ num := IntStr(line);
158+ while length(num) < 5 do num := ' ' + num;
159+ gutter := Paint(Blue, num + ' |');
160+ write(StdErr, gutter, ' ');
161+ for i := start to stop - 1 do write(StdErr, buf[i]);
162+ writeln(StdErr);
163+ write(StdErr, Paint(Blue, ' |'), ' ');
164+ for i := start to p.a - 1 do
165+ if buf[i] = #9 then write(StdErr, #9)
166+ else if (byte(buf[i]) and $C0) <> $80 then write(StdErr, ' ');
167+ if p.b < stop then n := Chars(buf, p.a, p.b) else n := Chars(buf, p.a, stop);
168+ if n < 1 then n := 1;
169+ writeln(StdErr, Paint(kindColour, StringOfChar('^', n)));
170+end;
171+
172+{ Messages }
173+
174+procedure Error(const p: TPos; const msg: shortstring);
175+begin
176+ Show(p, 'error', Red, msg);
177+ inc(errors);
178+ if errors >= MaxErrors then begin
179+ writeln(StdErr, 'raz: stopping after ', MaxErrors, ' errors');
180+ Halt(1);
181+ end;
182+end;
183+
184+procedure Warning(const p: TPos; const msg: shortstring);
185+begin
186+ if werror then Error(p, msg)
187+ else begin
188+ Show(p, 'warning', Yellow, msg);
189+ inc(warnings);
190+ end;
191+end;
192+
193+procedure Note(const p: TPos; const msg: shortstring);
194+begin
195+ Show(p, 'note', Cyan, msg);
196+end;
197+
198+procedure Help(const msg: shortstring);
199+begin
200+ writeln(StdErr, Paint(Green, 'help:'), ' ', msg);
201+end;
202+
203+{ An error with no place in the source, such as a file that can't be
204+ read: it stops the compiler at once. }
205+procedure Fatal(const msg: shortstring);
206+begin
207+ writeln(StdErr, 'raz: ', msg);
208+ Halt(1);
209+end;
210+
211+function Count(n: longint; const what: shortstring): shortstring;
212+begin
213+ if n = 1 then Count := '1 ' + what else Count := IntStr(n) + ' ' + what + 's';
214+end;
215+
216+{ Says how many errors and warnings there were, and stops the compiler
217+ if there were errors. }
218+procedure Finish;
219+begin
220+ if (errors > 0) and (warnings > 0) then
221+ writeln(StdErr, 'raz: ', Count(errors, 'error'), ', ', Count(warnings, 'warning'))
222+ else if errors > 0 then writeln(StdErr, 'raz: ', Count(errors, 'error'))
223+ else if warnings > 0 then writeln(StdErr, 'raz: ', Count(warnings, 'warning'));
224+ if errors > 0 then Halt(1);
225+end;
226+
227+end.

src/elf.pas modified +1 -1

@@ -24,7 +24,7 @@
2424
2525 interface
2626
27-uses scan, x64, link;
27+uses scan, diag, x64, link;
2828
2929 var
3030 needed: array[0..31] of longint; { the libraries to load, names interned }

src/gen.pas modified +1 -1

@@ -27,7 +27,7 @@
2727
2828 interface
2929
30-uses scan, sym, x64;
30+uses scan, diag, sym, x64;
3131
3232 type
3333 TMode = (mConst, mVar, mReg, mStack, mProc, mType, mStr, mBuiltin, mCase, mNone);

src/link.pas modified +1 -1

@@ -21,7 +21,7 @@
2121
2222 interface
2323
24-uses scan, x64;
24+uses scan, diag, x64;
2525
2626 const
2727 Base = $400000;

src/parse.pas modified +1 -1

@@ -21,7 +21,7 @@
2121
2222 interface
2323
24-uses scan, sym, x64, gen;
24+uses scan, diag, sym, x64, gen;
2525
2626 const
2727 Target = 'linux-x86_64';

src/raz.pas modified +6 -3

@@ -25,7 +25,7 @@
2525
2626 {$mode objfpc}{$H-}
2727
28-uses math, BaseUnix, syscall, scan, sym, x64, gen, parse, link, elf;
28+uses math, BaseUnix, syscall, scan, diag, sym, x64, gen, parse, link, elf;
2929
3030 const
3131 { what git describe says, made by make: 0.3.0 at the tag v0.3.0,
@@ -113,7 +113,9 @@
113113 end else if s = '-o' then begin
114114 inc(i);
115115 outPath := ParamStr(i);
116- end else if s = '--version' then begin
116+ end else if s = '-Werror' then
117+ werror := true
118+ else if s = '--version' then begin
117119 writeln('raz ', Version, ', report ', Report);
118120 Halt(0);
119121 end else if (s <> '') and (s[1] = '-') then
@@ -126,7 +128,7 @@
126128 inc(i);
127129 end;
128130 if path = '' then
129- Fatal('usage: raz [-I dir]... [-o file] Main.raz, or raz run [-I dir]... Main.raz [arg]...');
131+ Fatal('usage: raz [-I dir]... [-o file] [-Werror] Main.raz, or raz run [options] Main.raz [arg]...');
130132 if run and (outPath <> '') then Fatal('raz run takes no -o');
131133 dir := ParamStr(0);
132134 i := length(dir);
@@ -140,6 +142,7 @@
140142 end;
141143
142144 m := CompileMain(path);
145+ Finish;
143146
144147 Use(m);
145148 rt := firstModule;

src/scan.pas modified +15 -28

@@ -3,10 +3,10 @@
33 Reads a raz source file and hands the parser one symbol at a time:
44 reserved words, identifiers, numbers, characters, strings and
55 operators. Identifiers are interned, so that the rest of the compiler
6- compares names as small integers. The scanner also reports errors,
7- since it knows where in the file the compiler is.
6+ compares names as small integers. The scanner also says where the
7+ current symbol is, for messages.
88
9- Depends on: BaseUnix, to read files.
9+ Depends on: BaseUnix, to read files; diag, to report errors.
1010 Leaves out: recovery from errors. The first error stops the compiler. }
1111
1212 unit scan;
@@ -15,6 +15,8 @@
1515
1616 interface
1717
18+uses diag;
19+
1820 type
1921 TSym = (sNull, sIdent, sInt, sReal, sChar, sString,
2022 sPlus, sMinus, sTimes, sSlash, sEql, sNeq, sLss, sLeq, sGtr, sGeq,
@@ -43,6 +45,7 @@
4345 ival: int64;
4446 rval: double;
4547 id: longint;
48+ f: longint; { the file, as diag knows it }
4649 path: shortstring;
4750 end;
4851
@@ -63,10 +66,9 @@
6366 function Open(const path: shortstring): boolean;
6467 procedure Next;
6568 procedure Mark(const msg: shortstring);
66-procedure Fatal(const msg: shortstring);
6769 procedure SaveScan(var st: TScanState);
6870 procedure RestoreScan(const st: TScanState);
69-function Where: shortstring;
71+function TokPos: TPos;
7072 function CurPath: shortstring;
7173 function CurLine: longint;
7274
@@ -161,24 +163,14 @@
161163
162164 { Errors }
163165
164-function Column(pos: longint): longint;
165-var i, col: longint;
166+{ The current symbol }
167+function TokPos: TPos;
166168 begin
167- { counted in characters: every byte but a UTF-8 continuation byte }
168- col := 1;
169- for i := cur.tokLineStart to pos - 1 do
170- if (byte(cur.buf[i]) and $C0) <> $80 then inc(col);
171- Column := col;
169+ TokPos.f := cur.f;
170+ TokPos.a := cur.tokPos;
171+ TokPos.b := cur.pos;
172172 end;
173173
174-function Where: shortstring;
175-var l, c: shortstring;
176-begin
177- Str(cur.tokLine, l);
178- Str(Column(cur.tokPos), c);
179- Where := cur.path + ':' + l + ':' + c;
180-end;
181-
182174 function CurPath: shortstring;
183175 begin
184176 CurPath := cur.path;
@@ -189,16 +181,10 @@
189181 CurLine := cur.tokLine;
190182 end;
191183
192-procedure Fatal(const msg: shortstring);
193-begin
194- writeln(StdErr, 'raz: ', msg);
195- Halt(1);
196-end;
197-
198184 procedure Mark(const msg: shortstring);
199185 begin
200- writeln(StdErr, Where, ': ', msg);
201- Halt(1);
186+ Error(TokPos, msg);
187+ Finish;
202188 end;
203189
204190 { Files }
@@ -229,6 +215,7 @@
229215 cur.tokLine := 1;
230216 cur.tokLineStart := 0;
231217 cur.path := path;
218+ cur.f := AddFile(path, cur.buf, n);
232219 Open := true;
233220 end;
234221

test/check.sh (history) modified +2 -2

@@ -64,8 +64,8 @@
6464 if $raz -I test/err/mods -I test/run/mods -o $out/$name $f 2>$out/$name.cerr; then
6565 echo "FAIL $f: compiles"
6666 fail=$((fail + 1))
67- elif ! grep -qF "$(cat test/err/$name.err)" $out/$name.cerr; then
68- echo "FAIL $f: says $(cat $out/$name.cerr)"
67+ elif ! cmp -s test/err/$name.err $out/$name.cerr; then
68+ echo "FAIL $f: says"; diff test/err/$name.err $out/$name.cerr
6969 fail=$((fail + 1))
7070 else
7171 pass=$((pass + 1))

test/err/Assign.err modified +4 -1

@@ -1 +1,4 @@
1-can't use I32 as I64
1+test/err/Assign.raz:5:11: error: can't use I32 as I64
2+ 5 | a := b;
3+ | ^
4+raz: 1 error

test/err/BadProc.err modified +4 -1

@@ -1 +1,4 @@
1-needs a procedure with the signature of hash
1+/home/luis/raz/lib/Map.raz:4:39: error: needs a procedure with the signature of hash
2+ 4 | module Map(K, V; hash: proc(k: K): U64; eq: proc(a, b: K): BOOL);
3+ | ^
4+raz: 1 error

test/err/BigI64.err modified +4 -1

@@ -1 +1,4 @@
1-can't use U64 as I64
1+test/err/BigI64.raz:5:28: error: can't use U64 as I64
2+ 5 | i := 0FFFFFFFFFFFFFFFFH;
3+ | ^
4+raz: 1 error

test/err/Break.err modified +4 -1

@@ -1 +1,4 @@
1-break outside a loop
1+test/err/Break.raz:4:10: error: break outside a loop
2+ 4 | break;
3+ | ^
4+raz: 1 error

test/err/Cycle.err modified +4 -1

@@ -1 +1,4 @@
1-Cycle imports itself
1+test/err/mods/CycleB.raz:2:13: error: Cycle imports itself
2+ 2 | import Cycle;
3+ | ^
4+raz: 1 error

test/err/DeferBreak.err modified +4 -1

@@ -1 +1,4 @@
1-break outside a loop
1+test/err/DeferBreak.raz:5:20: error: break outside a loop
2+ 5 | defer break;
3+ | ^
4+raz: 1 error

test/err/DeferDefer.err modified +4 -1

@@ -1 +1,4 @@
1-defer can't be deferred
1+test/err/DeferDefer.raz:4:17: error: defer can't be deferred
2+ 4 | defer defer f;
3+ | ^
4+raz: 1 error

test/err/DeferReturn.err modified +4 -1

@@ -1 +1,4 @@
1-return can't leave a deferred statement
1+test/err/DeferReturn.raz:4:18: error: return can't leave a deferred statement
2+ 4 | defer return 1;
3+ | ^
4+raz: 1 error

test/err/ErrOrder.err modified +4 -1

@@ -1 +1,4 @@
1-compare only with = and #
1+test/err/ErrOrder.raz:5:14: error: procedures and errors compare only with = and #
2+ 5 | if A < B then end;
3+ | ^^^^
4+raz: 1 error

test/err/ExternRec.err (history) modified +4 -1

@@ -1 +1,4 @@
1-C takes integers, BOOL, reals, pointers and procedures
1+test/err/ExternRec.raz:5:20: error: C takes integers, BOOL, reals, pointers and procedures
2+ 5 | extern proc f(r: R);
3+ | ^
4+raz: 1 error

test/err/F32Dots.err (history) modified +4 -1

@@ -1 +1,4 @@
1-an F32 goes to ... as F64(x)
1+test/err/F32Dots.raz:8:23: error: an F32 goes to ... as F64(x)
2+ 8 | C.printf("%f\n", x);
3+ | ^
4+raz: 1 error

test/err/Field.err (history) modified +4 -1

@@ -1 +1,4 @@
1-field extra isn't exported
1+test/err/Field.raz:6:7: error: field extra isn't exported
2+ 6 | i.extra := 1;
3+ | ^^^^^
4+raz: 1 error

test/err/Match.err modified +4 -1

@@ -1 +1,4 @@
1-no arm for c
1+test/err/Match.raz:9:8: error: no arm for c
2+ 9 | end;
3+ | ^
4+raz: 1 error

test/err/Mixed.err modified +4 -1

@@ -1 +1,4 @@
1-different types: F32 and F64
1+test/err/Mixed.raz:6:15: error: different types: F32 and F64
2+ 6 | y := x + y;
3+ | ^
4+raz: 1 error

test/err/NegU64.err modified +4 -1

@@ -1 +1,4 @@
1-constant doesn't fit U64
1+test/err/NegU64.raz:5:12: error: constant doesn't fit U64
2+ 5 | u := -1;
3+ | ^
4+raz: 1 error

test/err/NoArgs.err modified +4 -1

@@ -1 +1,4 @@
1-needs a type for each type parameter
1+/home/luis/raz/lib/List.raz:2:13: error: needs a type for each type parameter
2+ 2 | module List(T);
3+ | ^
4+raz: 1 error

test/err/NotGeneric.err modified +4 -1

@@ -1 +1,4 @@
1-Str isn't generic
1+/home/luis/raz/lib/Str.raz:3:11: error: Str isn't generic
2+ 3 | module Str;
3+ | ^
4+raz: 1 error

test/err/PtrArray.err modified +4 -1

@@ -1 +1,4 @@
1-a pointer to an array is indexed as p^[i]
1+test/err/PtrArray.raz:6:7: error: a pointer to an array is indexed as p^[i]
2+ 6 | p[1] := 0;
3+ | ^
4+raz: 1 error

test/err/Static.err (history) modified +1 -1

@@ -1 +1 @@
1-Bare says link static, but
1+raz: Bare says link static, but C uses C

test/err/ThreadC.err modified +1 -1

@@ -1 +1 @@
1-Thread says link static, but
1+raz: Thread says link static, but C uses C

test/err/Tuple.err modified +4 -1

@@ -1 +1,4 @@
1-several results go only to a, b := ...
1+test/err/Tuple.raz:6:16: error: several results go only to a, b := ...
2+ 6 | a := two() + 1;
3+ | ^
4+raz: 1 error

test/err/TwoTypes.err modified +4 -1

@@ -1 +1,4 @@
1-can't use List(I32).List as List(I64).List
1+test/err/TwoTypes.raz:6:11: error: can't use List(I32).List as List(I64).List
2+ 6 | a := b;
3+ | ^
4+raz: 1 error

test/err/UsesExtra.err (history) modified +1 -1

@@ -1 +1 @@
1-more isn't exported by
1+raz: test/err/mods/Extra.raz: more isn't exported by test/err/mods/Extra.linux.raz

test/err/UsesIface.err (history) modified +1 -1

@@ -1 +1 @@
1-f isn't exported as in
1+raz: test/err/mods/Iface.raz: f isn't exported as in test/err/mods/Iface.linux-x86_64.raz

test/err/UsesRec.err (history) modified +1 -1

@@ -1 +1 @@
1-R isn't exported as in
1+raz: test/err/mods/Rec.raz: R isn't exported as in test/err/mods/Rec.linux-x86_64.raz

test/err/Utf.err modified +4 -1

@@ -1 +1,4 @@
1-Utf.raz:2:5: text outside strings, characters and comments must be ASCII
1+test/err/Utf.raz:2:5: error: text outside strings, characters and comments must be ASCII
2+ 2 | var é: I64;
3+ | ^
4+raz: 1 error

test/err/Variadic.err (history) modified +4 -1

@@ -1 +1,4 @@
1-... is only for extern procedures
1+test/err/Variadic.raz:3:16: error: ... is only for extern procedures
2+ 3 | proc f(a: I64; ...);
3+ | ^^^
4+raz: 1 error

test/err/Volatile.err modified +4 -1

@@ -1 +1,4 @@
1-can't use ^VOLATILE I64 as ^I64
1+test/err/Volatile.raz:6:11: error: can't use ^VOLATILE I64 as ^I64
2+ 6 | q := p;
3+ | ^
4+raz: 1 error

test/scantest.pas modified +2 -2

@@ -1,13 +1,13 @@
11 { Prints the symbols of a file, one per line: a test of scan.pas. }
22 program scantest;
33 {$mode objfpc}{$H-}
4-uses scan;
4+uses diag, scan;
55 var i: longint;
66 begin
77 if not Open(ParamStr(1)) then Fatal('no file');
88 repeat
99 Next;
10- write(Where, ' ', ord(tok));
10+ write(LineOf(TokPos), ':', TokPos.a, ' ', ord(tok));
1111 case tok of
1212 sIdent: write(' ', NameOf(id));
1313 sInt, sChar: write(' ', ival);