From cb2bb1899bc9b216e63d68df2ae3e7c456ee1884 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Sun, 11 Oct 2026 00:57:14 +0100 Subject: [PATCH] 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. --- diff --git a/Makefile b/Makefile index bfcd96a..8a09b4c 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ FORCE: units: src/*.pas | build - for u in scan sym x64 link elf; do $(FPC) $(FPCFLAGS) src/$$u.pas || exit 1; done + for u in diag scan sym x64 link elf; do $(FPC) $(FPCFLAGS) src/$$u.pas || exit 1; done # tests of the parts below the parser, built from test/ tests: units diff --git a/PLAN.md b/PLAN.md index f776ed3..eee302e 100644 --- a/PLAN.md +++ b/PLAN.md @@ -191,7 +191,7 @@ T.raz:3:5: note: x is declared here 3 | var x: I64; | ^ -T.raz: 1 error +raz: 1 error ``` How messages are worded, for every step that writes one: lowercase, @@ -211,9 +211,9 @@ - [x] 19. The report first, for review before any code: messages, warnings and `-Werror` in section 10, run-time messages in sections 6.5 and 10, report version `2026-10.1`. *main* -- [ ] 20. `src/diag.pas`, the one place messages are made: a position - (file, line, first and last column) and a message built in - pieces, past shortstring's 255 characters; the source excerpt +- [x] 20. `src/diag.pas`, the one place messages are made: a position + (a file and a stretch of bytes, its line and columns worked out + only for a message); the source excerpt and its underline, colour, notes and help; counting errors and warnings, the summary, `-Werror`, the exit status. `Mark` and `Fatal` move there. `test/err` and `test/pretty` keep working: diff --git a/README.md b/README.md index 995c962..2870c10 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,8 @@ ## Using it - raz [-I dir]... [-o file] Main.raz - raz run [-I dir]... Main.raz [arg]... + raz [-I dir]... [-o file] [-Werror] Main.raz + raz run [-I dir]... [-Werror] Main.raz [arg]... raz --version `raz Main.raz` compiles module `Main` and every module it imports, and @@ -77,7 +77,8 @@ in the main module's directory, then in each `-I` directory, then in `lib`. A module whose code depends on the system comes in one file per target, `Name.linux-x86_64.raz` before `Name.raz`; the compiler checks -that all of them export the same things. +that all of them export the same things. `-Werror` makes warnings +errors. `raz run Main.raz a b` compiles the same way, then runs the program with the arguments `a b`, writing no file: its output and exit status diff --git a/doc/compiler.md b/doc/compiler.md index 095976f..a677721 100644 --- a/doc/compiler.md +++ b/doc/compiler.md @@ -1,6 +1,6 @@ # Reading the raz compiler -The compiler is eight files of Free Pascal, under 5,000 lines of code. +The compiler is nine files of Free Pascal, under 6,000 lines of code. This guide walks through them in the order they are best read: from the characters of a source file to the bytes of an executable. It assumes you know the language from `doc/raz.md`, and enough x86-64 to read a @@ -8,14 +8,15 @@ | File | Lines | Code | What | |---|---|---|---| -| `src/scan.pas` | 548 | 471 | Symbols, literals, comments, error messages | +| `src/diag.pas` | 227 | 162 | Messages: positions, source excerpts, colour, counts | +| `src/scan.pas` | 535 | 459 | Symbols, literals, comments, positions | | `src/sym.pas` | 508 | 422 | Types, objects, scopes, layout | | `src/x64.pas` | 680 | 546 | Code buffer, chunks, fixups, line notes, instruction encoder | | `src/gen.pas` | 1,414 | 1,240 | Items: loading, storing, copying, frames, calls | | `src/parse.pas` | 1,816 | 1,685 | Declarations, statements, expressions, built-ins | | `src/link.pas` | 131 | 95 | Tree shaking, layout, patching | | `src/elf.pas` | 425 | 351 | Static and dynamic ELF, symbol table, line numbers | -| `src/raz.pas` | 216 | 169 | The command line, the entry points | +| `src/raz.pas` | 219 | 172 | The command line, the entry points | Every file opens with a comment that says what it is, what it depends on and what it leaves out. Read those first; they are the map. @@ -111,6 +112,18 @@ is not fast code. It is code whose every instruction you can account for, which is the point. +## diag.pas: messages + +Every message the compiler prints is made here. A position, `TPos`, is +a file and a stretch of bytes in it; `Error`, `Warning` and `Note` show +it as `file:line:column`, then the line of source with the stretch +underlined, and `Help` adds a line of advice. The line and column are +worked out only when a message is printed (`Locate`, `Chars`), so +positions cost nothing while compiling. `AddFile` keeps every source +file the scanner opens, so a note can show a line of any of them. +`Finish` prints the count of errors and warnings and stops if there +were errors; `Fatal` is for errors with no place in the source. + ## scan.pas: the scanner The scanner turns bytes into symbols (`TSym`). The current symbol is in @@ -132,9 +145,9 @@ Source is UTF-8, checked by `Utf8` wherever a byte above 127 appears: in strings, characters and comments. Anywhere else it is an error. -Errors go through `Mark`, which prints `file:line:column` (the column -counted in characters, by `Column`) and stops. There is no recovery: -the first error ends the compilation. `SaveScan` and `RestoreScan` keep +`TokPos` is the position of the current symbol. Errors go through +`Mark`, which reports one there (`diag.Error`) and stops. There is no +recovery: the first error ends the compilation. `SaveScan` and `RestoreScan` keep the scanner's state while an imported module is compiled. ## sym.pas: types, objects and scopes diff --git a/src/diag.pas b/src/diag.pas new file mode 100644 index 0000000..d3b10dc --- /dev/null +++ b/src/diag.pas @@ -0,0 +1,227 @@ +{ diag.pas: messages. + + The one place the compiler's messages are made. A message is an + error or a warning at a position, which it shows as the file, line + and column, then the line of source with the position underlined; + notes, each at a position of its own, and help, a line of advice, + may follow it. Colour is used when standard error is a terminal and + NO_COLOR isn't set. diag keeps every source file it is given, so + that a note can show a line of a module compiled earlier. + + Depends on: BaseUnix and termio, to write and to ask about the + terminal. + Leaves out: wording. The callers say what is wrong; a message is at + most 255 characters, which every message so far keeps well within. } + +unit diag; + +{$mode objfpc}{$H-} + +interface + +type + { A stretch of a source file: bytes a up to but not including b. + a = b marks the place between two characters. } + TPos = record + f, a, b: longint; + end; + +const + MaxErrors = 20; + +var + errors, warnings: longint; + werror: boolean; { -Werror: a warning counts as an error } + +function AddFile(const path: shortstring; buf: PChar; len: longint): longint; +function PathOf(f: longint): shortstring; +function LineOf(const p: TPos): longint; +procedure Error(const p: TPos; const msg: shortstring); +procedure Warning(const p: TPos; const msg: shortstring); +procedure Note(const p: TPos; const msg: shortstring); +procedure Help(const msg: shortstring); +procedure Fatal(const msg: shortstring); +procedure Finish; + +implementation + +uses BaseUnix, termio; + +type + TFile = record + path: shortstring; + buf: PChar; + len: longint; + end; + +var + files: ^TFile; { numFiles of them, in room for cap } + numFiles, cap: longint; + colour, colourKnown: boolean; + +function AddFile(const path: shortstring; buf: PChar; len: longint): longint; +begin + if numFiles = cap then begin + cap := 2 * cap + 8; + ReallocMem(files, cap * SizeOf(TFile)); + end; + files[numFiles].path := path; + files[numFiles].buf := buf; + files[numFiles].len := len; + AddFile := numFiles; + inc(numFiles); +end; + +function PathOf(f: longint): shortstring; +begin + PathOf := files[f].path; +end; + +{ Writing } + +const + Bold = #27'[1m'; Red = #27'[1;31m'; Yellow = #27'[1;33m'; + Cyan = #27'[1;36m'; Green = #27'[1;32m'; Blue = #27'[1;34m'; + Plain = #27'[0m'; + +{ Whether NO_COLOR is set, to anything } +function NoColour: boolean; +var e: PPChar; +begin + e := envp; + while (e^ <> nil) and (CompareByte(e^^, PChar('NO_COLOR=')^, 9) <> 0) do inc(e); + NoColour := e^ <> nil; +end; + +{ s in colour c, when colour is on } +function Paint(const c, s: shortstring): shortstring; +begin + if not colourKnown then begin + colour := (IsATTY(2) = 1) and not NoColour; + colourKnown := true; + end; + if colour then Paint := c + s + Plain else Paint := s; +end; + +function IntStr(n: longint): shortstring; +var s: shortstring; +begin + Str(n, s); + IntStr := s; +end; + +{ Positions } + +{ The line of p, and the byte where it starts. Lines are counted from + the start of the file, which is slow only next to compiling it. } +procedure Locate(const p: TPos; out line, start: longint); +var i: longint; buf: PChar; +begin + buf := files[p.f].buf; + line := 1; start := 0; + for i := 0 to p.a - 1 do + if buf[i] = #10 then begin inc(line); start := i + 1 end; +end; + +function LineOf(const p: TPos): longint; +var line, start: longint; +begin + Locate(p, line, start); + LineOf := line; +end; + +{ Characters from byte i to byte j of buf: every byte but a UTF-8 + continuation byte. } +function Chars(buf: PChar; i, j: longint): longint; +var n: longint; +begin + n := 0; + for i := i to j - 1 do + if (byte(buf[i]) and $C0) <> $80 then inc(n); + Chars := n; +end; + +{ "file:line:col: kind: msg", then the line with p underlined. A tab + before p is copied into the underline, so that the two line up + whatever the terminal makes of tabs. } +procedure Show(const p: TPos; const kind, kindColour, msg: shortstring); +var line, start, stop, i, n: longint; buf: PChar; num, gutter: shortstring; +begin + Locate(p, line, start); + buf := files[p.f].buf; + writeln(StdErr, Paint(Bold, files[p.f].path + ':' + IntStr(line) + ':' + + IntStr(Chars(buf, start, p.a) + 1) + ':'), ' ', Paint(kindColour, kind + ':'), + ' ', Paint(Bold, msg)); + stop := start; + while (stop < files[p.f].len) and (buf[stop] <> #10) do inc(stop); + num := IntStr(line); + while length(num) < 5 do num := ' ' + num; + gutter := Paint(Blue, num + ' |'); + write(StdErr, gutter, ' '); + for i := start to stop - 1 do write(StdErr, buf[i]); + writeln(StdErr); + write(StdErr, Paint(Blue, ' |'), ' '); + for i := start to p.a - 1 do + if buf[i] = #9 then write(StdErr, #9) + else if (byte(buf[i]) and $C0) <> $80 then write(StdErr, ' '); + if p.b < stop then n := Chars(buf, p.a, p.b) else n := Chars(buf, p.a, stop); + if n < 1 then n := 1; + writeln(StdErr, Paint(kindColour, StringOfChar('^', n))); +end; + +{ Messages } + +procedure Error(const p: TPos; const msg: shortstring); +begin + Show(p, 'error', Red, msg); + inc(errors); + if errors >= MaxErrors then begin + writeln(StdErr, 'raz: stopping after ', MaxErrors, ' errors'); + Halt(1); + end; +end; + +procedure Warning(const p: TPos; const msg: shortstring); +begin + if werror then Error(p, msg) + else begin + Show(p, 'warning', Yellow, msg); + inc(warnings); + end; +end; + +procedure Note(const p: TPos; const msg: shortstring); +begin + Show(p, 'note', Cyan, msg); +end; + +procedure Help(const msg: shortstring); +begin + writeln(StdErr, Paint(Green, 'help:'), ' ', msg); +end; + +{ An error with no place in the source, such as a file that can't be + read: it stops the compiler at once. } +procedure Fatal(const msg: shortstring); +begin + writeln(StdErr, 'raz: ', msg); + Halt(1); +end; + +function Count(n: longint; const what: shortstring): shortstring; +begin + if n = 1 then Count := '1 ' + what else Count := IntStr(n) + ' ' + what + 's'; +end; + +{ Says how many errors and warnings there were, and stops the compiler + if there were errors. } +procedure Finish; +begin + if (errors > 0) and (warnings > 0) then + writeln(StdErr, 'raz: ', Count(errors, 'error'), ', ', Count(warnings, 'warning')) + else if errors > 0 then writeln(StdErr, 'raz: ', Count(errors, 'error')) + else if warnings > 0 then writeln(StdErr, 'raz: ', Count(warnings, 'warning')); + if errors > 0 then Halt(1); +end; + +end. diff --git a/src/elf.pas b/src/elf.pas index dfdbd33..9a8982f 100644 --- a/src/elf.pas +++ b/src/elf.pas @@ -24,7 +24,7 @@ interface -uses scan, x64, link; +uses scan, diag, x64, link; var needed: array[0..31] of longint; { the libraries to load, names interned } diff --git a/src/gen.pas b/src/gen.pas index 9df19f7..6e73f9b 100644 --- a/src/gen.pas +++ b/src/gen.pas @@ -27,7 +27,7 @@ interface -uses scan, sym, x64; +uses scan, diag, sym, x64; type TMode = (mConst, mVar, mReg, mStack, mProc, mType, mStr, mBuiltin, mCase, mNone); diff --git a/src/link.pas b/src/link.pas index d3c55ff..c32541b 100644 --- a/src/link.pas +++ b/src/link.pas @@ -21,7 +21,7 @@ interface -uses scan, x64; +uses scan, diag, x64; const Base = $400000; diff --git a/src/parse.pas b/src/parse.pas index 041029d..e27743a 100644 --- a/src/parse.pas +++ b/src/parse.pas @@ -21,7 +21,7 @@ interface -uses scan, sym, x64, gen; +uses scan, diag, sym, x64, gen; const Target = 'linux-x86_64'; diff --git a/src/raz.pas b/src/raz.pas index 39f3ccb..1b9e2b0 100644 --- a/src/raz.pas +++ b/src/raz.pas @@ -25,7 +25,7 @@ {$mode objfpc}{$H-} -uses math, BaseUnix, syscall, scan, sym, x64, gen, parse, link, elf; +uses math, BaseUnix, syscall, scan, diag, sym, x64, gen, parse, link, elf; const { what git describe says, made by make: 0.3.0 at the tag v0.3.0, @@ -113,7 +113,9 @@ end else if s = '-o' then begin inc(i); outPath := ParamStr(i); - end else if s = '--version' then begin + end else if s = '-Werror' then + werror := true + else if s = '--version' then begin writeln('raz ', Version, ', report ', Report); Halt(0); end else if (s <> '') and (s[1] = '-') then @@ -126,7 +128,7 @@ inc(i); end; if path = '' then - Fatal('usage: raz [-I dir]... [-o file] Main.raz, or raz run [-I dir]... Main.raz [arg]...'); + Fatal('usage: raz [-I dir]... [-o file] [-Werror] Main.raz, or raz run [options] Main.raz [arg]...'); if run and (outPath <> '') then Fatal('raz run takes no -o'); dir := ParamStr(0); i := length(dir); @@ -140,6 +142,7 @@ end; m := CompileMain(path); + Finish; Use(m); rt := firstModule; diff --git a/src/scan.pas b/src/scan.pas index 1290c7e..dac167c 100644 --- a/src/scan.pas +++ b/src/scan.pas @@ -3,10 +3,10 @@ Reads a raz source file and hands the parser one symbol at a time: reserved words, identifiers, numbers, characters, strings and operators. Identifiers are interned, so that the rest of the compiler - compares names as small integers. The scanner also reports errors, - since it knows where in the file the compiler is. + compares names as small integers. The scanner also says where the + current symbol is, for messages. - Depends on: BaseUnix, to read files. + Depends on: BaseUnix, to read files; diag, to report errors. Leaves out: recovery from errors. The first error stops the compiler. } unit scan; @@ -15,6 +15,8 @@ interface +uses diag; + type TSym = (sNull, sIdent, sInt, sReal, sChar, sString, sPlus, sMinus, sTimes, sSlash, sEql, sNeq, sLss, sLeq, sGtr, sGeq, @@ -43,6 +45,7 @@ ival: int64; rval: double; id: longint; + f: longint; { the file, as diag knows it } path: shortstring; end; @@ -63,10 +66,9 @@ function Open(const path: shortstring): boolean; procedure Next; procedure Mark(const msg: shortstring); -procedure Fatal(const msg: shortstring); procedure SaveScan(var st: TScanState); procedure RestoreScan(const st: TScanState); -function Where: shortstring; +function TokPos: TPos; function CurPath: shortstring; function CurLine: longint; @@ -161,24 +163,14 @@ { Errors } -function Column(pos: longint): longint; -var i, col: longint; +{ The current symbol } +function TokPos: TPos; begin - { counted in characters: every byte but a UTF-8 continuation byte } - col := 1; - for i := cur.tokLineStart to pos - 1 do - if (byte(cur.buf[i]) and $C0) <> $80 then inc(col); - Column := col; + TokPos.f := cur.f; + TokPos.a := cur.tokPos; + TokPos.b := cur.pos; end; -function Where: shortstring; -var l, c: shortstring; -begin - Str(cur.tokLine, l); - Str(Column(cur.tokPos), c); - Where := cur.path + ':' + l + ':' + c; -end; - function CurPath: shortstring; begin CurPath := cur.path; @@ -189,16 +181,10 @@ CurLine := cur.tokLine; end; -procedure Fatal(const msg: shortstring); -begin - writeln(StdErr, 'raz: ', msg); - Halt(1); -end; - procedure Mark(const msg: shortstring); begin - writeln(StdErr, Where, ': ', msg); - Halt(1); + Error(TokPos, msg); + Finish; end; { Files } @@ -229,6 +215,7 @@ cur.tokLine := 1; cur.tokLineStart := 0; cur.path := path; + cur.f := AddFile(path, cur.buf, n); Open := true; end; diff --git a/test/check.sh b/test/check.sh index 1817711..5917e4c 100755 --- a/test/check.sh +++ b/test/check.sh @@ -64,8 +64,8 @@ if $raz -I test/err/mods -I test/run/mods -o $out/$name $f 2>$out/$name.cerr; then echo "FAIL $f: compiles" fail=$((fail + 1)) - elif ! grep -qF "$(cat test/err/$name.err)" $out/$name.cerr; then - echo "FAIL $f: says $(cat $out/$name.cerr)" + elif ! cmp -s test/err/$name.err $out/$name.cerr; then + echo "FAIL $f: says"; diff test/err/$name.err $out/$name.cerr fail=$((fail + 1)) else pass=$((pass + 1)) diff --git a/test/err/Assign.err b/test/err/Assign.err index 138914e..45cb220 100644 --- a/test/err/Assign.err +++ b/test/err/Assign.err @@ -1 +1,4 @@ -can't use I32 as I64 +test/err/Assign.raz:5:11: error: can't use I32 as I64 + 5 | a := b; + | ^ +raz: 1 error diff --git a/test/err/BadProc.err b/test/err/BadProc.err index 4e86a72..10ad4a1 100644 --- a/test/err/BadProc.err +++ b/test/err/BadProc.err @@ -1 +1,4 @@ -needs a procedure with the signature of hash +/home/luis/raz/lib/Map.raz:4:39: error: needs a procedure with the signature of hash + 4 | module Map(K, V; hash: proc(k: K): U64; eq: proc(a, b: K): BOOL); + | ^ +raz: 1 error diff --git a/test/err/BigI64.err b/test/err/BigI64.err index ae5d055..fd08ea1 100644 --- a/test/err/BigI64.err +++ b/test/err/BigI64.err @@ -1 +1,4 @@ -can't use U64 as I64 +test/err/BigI64.raz:5:28: error: can't use U64 as I64 + 5 | i := 0FFFFFFFFFFFFFFFFH; + | ^ +raz: 1 error diff --git a/test/err/Break.err b/test/err/Break.err index fa5a823..b925eb6 100644 --- a/test/err/Break.err +++ b/test/err/Break.err @@ -1 +1,4 @@ -break outside a loop +test/err/Break.raz:4:10: error: break outside a loop + 4 | break; + | ^ +raz: 1 error diff --git a/test/err/Cycle.err b/test/err/Cycle.err index b81dc1f..bd9e32c 100644 --- a/test/err/Cycle.err +++ b/test/err/Cycle.err @@ -1 +1,4 @@ -Cycle imports itself +test/err/mods/CycleB.raz:2:13: error: Cycle imports itself + 2 | import Cycle; + | ^ +raz: 1 error diff --git a/test/err/DeferBreak.err b/test/err/DeferBreak.err index fa5a823..9188b80 100644 --- a/test/err/DeferBreak.err +++ b/test/err/DeferBreak.err @@ -1 +1,4 @@ -break outside a loop +test/err/DeferBreak.raz:5:20: error: break outside a loop + 5 | defer break; + | ^ +raz: 1 error diff --git a/test/err/DeferDefer.err b/test/err/DeferDefer.err index a25f3db..ba151df 100644 --- a/test/err/DeferDefer.err +++ b/test/err/DeferDefer.err @@ -1 +1,4 @@ -defer can't be deferred +test/err/DeferDefer.raz:4:17: error: defer can't be deferred + 4 | defer defer f; + | ^ +raz: 1 error diff --git a/test/err/DeferReturn.err b/test/err/DeferReturn.err index dcaca3b..739bddd 100644 --- a/test/err/DeferReturn.err +++ b/test/err/DeferReturn.err @@ -1 +1,4 @@ -return can't leave a deferred statement +test/err/DeferReturn.raz:4:18: error: return can't leave a deferred statement + 4 | defer return 1; + | ^ +raz: 1 error diff --git a/test/err/ErrOrder.err b/test/err/ErrOrder.err index 2913f0c..45b2eda 100644 --- a/test/err/ErrOrder.err +++ b/test/err/ErrOrder.err @@ -1 +1,4 @@ -compare only with = and # +test/err/ErrOrder.raz:5:14: error: procedures and errors compare only with = and # + 5 | if A < B then end; + | ^^^^ +raz: 1 error diff --git a/test/err/ExternRec.err b/test/err/ExternRec.err index 9fe8e4e..36db9af 100644 --- a/test/err/ExternRec.err +++ b/test/err/ExternRec.err @@ -1 +1,4 @@ -C takes integers, BOOL, reals, pointers and procedures +test/err/ExternRec.raz:5:20: error: C takes integers, BOOL, reals, pointers and procedures + 5 | extern proc f(r: R); + | ^ +raz: 1 error diff --git a/test/err/F32Dots.err b/test/err/F32Dots.err index c1fd5a4..fd761dc 100644 --- a/test/err/F32Dots.err +++ b/test/err/F32Dots.err @@ -1 +1,4 @@ -an F32 goes to ... as F64(x) +test/err/F32Dots.raz:8:23: error: an F32 goes to ... as F64(x) + 8 | C.printf("%f\n", x); + | ^ +raz: 1 error diff --git a/test/err/Field.err b/test/err/Field.err index 81be2a4..6e910de 100644 --- a/test/err/Field.err +++ b/test/err/Field.err @@ -1 +1,4 @@ -field extra isn't exported +test/err/Field.raz:6:7: error: field extra isn't exported + 6 | i.extra := 1; + | ^^^^^ +raz: 1 error diff --git a/test/err/Match.err b/test/err/Match.err index f32c48a..19cc8e6 100644 --- a/test/err/Match.err +++ b/test/err/Match.err @@ -1 +1,4 @@ -no arm for c +test/err/Match.raz:9:8: error: no arm for c + 9 | end; + | ^ +raz: 1 error diff --git a/test/err/Mixed.err b/test/err/Mixed.err index bae9e76..8afa78e 100644 --- a/test/err/Mixed.err +++ b/test/err/Mixed.err @@ -1 +1,4 @@ -different types: F32 and F64 +test/err/Mixed.raz:6:15: error: different types: F32 and F64 + 6 | y := x + y; + | ^ +raz: 1 error diff --git a/test/err/NegU64.err b/test/err/NegU64.err index 53be09c..5fea6b7 100644 --- a/test/err/NegU64.err +++ b/test/err/NegU64.err @@ -1 +1,4 @@ -constant doesn't fit U64 +test/err/NegU64.raz:5:12: error: constant doesn't fit U64 + 5 | u := -1; + | ^ +raz: 1 error diff --git a/test/err/NoArgs.err b/test/err/NoArgs.err index 10303bf..f3f1253 100644 --- a/test/err/NoArgs.err +++ b/test/err/NoArgs.err @@ -1 +1,4 @@ -needs a type for each type parameter +/home/luis/raz/lib/List.raz:2:13: error: needs a type for each type parameter + 2 | module List(T); + | ^ +raz: 1 error diff --git a/test/err/NotGeneric.err b/test/err/NotGeneric.err index 0945d7b..1e9a919 100644 --- a/test/err/NotGeneric.err +++ b/test/err/NotGeneric.err @@ -1 +1,4 @@ -Str isn't generic +/home/luis/raz/lib/Str.raz:3:11: error: Str isn't generic + 3 | module Str; + | ^ +raz: 1 error diff --git a/test/err/PtrArray.err b/test/err/PtrArray.err index 80ec6ba..0a4a351 100644 --- a/test/err/PtrArray.err +++ b/test/err/PtrArray.err @@ -1 +1,4 @@ -a pointer to an array is indexed as p^[i] +test/err/PtrArray.raz:6:7: error: a pointer to an array is indexed as p^[i] + 6 | p[1] := 0; + | ^ +raz: 1 error diff --git a/test/err/Static.err b/test/err/Static.err index c97362b..2ad6c75 100644 --- a/test/err/Static.err +++ b/test/err/Static.err @@ -1 +1 @@ -Bare says link static, but +raz: Bare says link static, but C uses C diff --git a/test/err/ThreadC.err b/test/err/ThreadC.err index bd6f33d..c382840 100644 --- a/test/err/ThreadC.err +++ b/test/err/ThreadC.err @@ -1 +1 @@ -Thread says link static, but +raz: Thread says link static, but C uses C diff --git a/test/err/Tuple.err b/test/err/Tuple.err index 252c0bc..e8fa6e4 100644 --- a/test/err/Tuple.err +++ b/test/err/Tuple.err @@ -1 +1,4 @@ -several results go only to a, b := ... +test/err/Tuple.raz:6:16: error: several results go only to a, b := ... + 6 | a := two() + 1; + | ^ +raz: 1 error diff --git a/test/err/TwoTypes.err b/test/err/TwoTypes.err index ebb66ba..fc46b23 100644 --- a/test/err/TwoTypes.err +++ b/test/err/TwoTypes.err @@ -1 +1,4 @@ -can't use List(I32).List as List(I64).List +test/err/TwoTypes.raz:6:11: error: can't use List(I32).List as List(I64).List + 6 | a := b; + | ^ +raz: 1 error diff --git a/test/err/UsesExtra.err b/test/err/UsesExtra.err index 0fffaad..c327492 100644 --- a/test/err/UsesExtra.err +++ b/test/err/UsesExtra.err @@ -1 +1 @@ -more isn't exported by +raz: test/err/mods/Extra.raz: more isn't exported by test/err/mods/Extra.linux.raz diff --git a/test/err/UsesIface.err b/test/err/UsesIface.err index 772b8ad..a5e6929 100644 --- a/test/err/UsesIface.err +++ b/test/err/UsesIface.err @@ -1 +1 @@ -f isn't exported as in +raz: test/err/mods/Iface.raz: f isn't exported as in test/err/mods/Iface.linux-x86_64.raz diff --git a/test/err/UsesRec.err b/test/err/UsesRec.err index d7a8520..b191474 100644 --- a/test/err/UsesRec.err +++ b/test/err/UsesRec.err @@ -1 +1 @@ -R isn't exported as in +raz: test/err/mods/Rec.raz: R isn't exported as in test/err/mods/Rec.linux-x86_64.raz diff --git a/test/err/Utf.err b/test/err/Utf.err index 6127c87..13b1d99 100644 --- a/test/err/Utf.err +++ b/test/err/Utf.err @@ -1 +1,4 @@ -Utf.raz:2:5: text outside strings, characters and comments must be ASCII +test/err/Utf.raz:2:5: error: text outside strings, characters and comments must be ASCII + 2 | var é: I64; + | ^ +raz: 1 error diff --git a/test/err/Variadic.err b/test/err/Variadic.err index 531ee7b..924371f 100644 --- a/test/err/Variadic.err +++ b/test/err/Variadic.err @@ -1 +1,4 @@ -... is only for extern procedures +test/err/Variadic.raz:3:16: error: ... is only for extern procedures + 3 | proc f(a: I64; ...); + | ^^^ +raz: 1 error diff --git a/test/err/Volatile.err b/test/err/Volatile.err index ed941bc..b47bcfb 100644 --- a/test/err/Volatile.err +++ b/test/err/Volatile.err @@ -1 +1,4 @@ -can't use ^VOLATILE I64 as ^I64 +test/err/Volatile.raz:6:11: error: can't use ^VOLATILE I64 as ^I64 + 6 | q := p; + | ^ +raz: 1 error diff --git a/test/scantest.pas b/test/scantest.pas index 9fe6a7b..7623e20 100644 --- a/test/scantest.pas +++ b/test/scantest.pas @@ -1,13 +1,13 @@ { Prints the symbols of a file, one per line: a test of scan.pas. } program scantest; {$mode objfpc}{$H-} -uses scan; +uses diag, scan; var i: longint; begin if not Open(ParamStr(1)) then Fatal('no file'); repeat Next; - write(Where, ' ', ord(tok)); + write(LineOf(TokPos), ':', TokPos.a, ' ', ord(tok)); case tok of sIdent: write(' ', NameOf(id)); sInt, sChar: write(' ', ival);