raz / commit 339451e9

commit
339451e9a9cabd847655a1209e1bcef1c04a001e
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
0d7e2bdb
Every message reworded, each with a test

Messages follow stage 4's rules: lowercase, the things involved
named, what was expected and what was found. A missing symbol says
`expected ";", found "end"` (scan's Found and SymText, parse's
Expect and Expected); operators that don't apply say `"+" doesn't
apply to BOOL`; constants and indexes give their values. MarkHelp
adds a line of help. 119 new tests in test/err pin each message and
its place; those left untested need command-line options, huge
inputs, or can't be reached.

patch · log

282 files changed, +1755 -286

PLAN.md (history) modified +1 -1

@@ -244,7 +244,7 @@
244244 and fails on a crash or two messages at one place. Writing it
245245 and sorting what it finds, *agent*; the fixes in `gen.pas`,
246246 *main*.
247-- [ ] 23. Every message reworded to the rules above, each with a test
247+- [x] 23. Every message reworded to the rules above, each with a test
248248 in `test/err` that pins its position too. *agent*, one per file
249249 (`scan.pas`, `parse.pas` in two halves, `gen.pas`, the rest),
250250 against a list of messages and their tests the main model writes

doc/compiler.md (history) modified +11 -7

@@ -8,12 +8,12 @@
88
99 | File | Lines | Code | What |
1010 |---|---|---|---|
11-| `src/diag.pas` | 248 | 177 | Messages: positions, source excerpts, colour, counts |
12-| `src/scan.pas` | 612 | 509 | Symbols, literals, comments, positions |
11+| `src/diag.pas` | 249 | 178 | Messages: positions, source excerpts, colour, counts |
12+| `src/scan.pas` | 660 | 529 | Symbols, literals, comments, positions |
1313 | `src/sym.pas` | 526 | 437 | Types, objects, scopes, layout |
1414 | `src/x64.pas` | 682 | 548 | Code buffer, chunks, fixups, line notes, instruction encoder |
15-| `src/gen.pas` | 1,468 | 1,281 | Items: loading, storing, copying, frames, calls |
16-| `src/parse.pas` | 2,053 | 1,873 | Declarations, statements, expressions, built-ins, recovery |
15+| `src/gen.pas` | 1,492 | 1,303 | Items: loading, storing, copying, frames, calls |
16+| `src/parse.pas` | 2,094 | 1,908 | Declarations, statements, expressions, built-ins, recovery |
1717 | `src/link.pas` | 131 | 95 | Tree shaking, layout, patching |
1818 | `src/elf.pas` | 425 | 351 | Static and dynamic ELF, symbol table, line numbers |
1919 | `src/raz.pas` | 219 | 172 | The command line, the entry points |
@@ -143,9 +143,13 @@
143143 from a saved position to the end of the symbol before the current one,
144144 and `MissingPos` the place to say a symbol is missing: just after the
145145 symbol before, when the current one starts a new line. Errors go
146-through `Mark`, at the current symbol, or `MarkAt`, at a position; each
147-reports the error (`diag.Error`) and jumps to `recovery`, the parser's
148-place to go on from (see parse.pas). Errors in the text itself stop the
146+through `Mark`, at the current symbol, `MarkAt`, at a position, or
147+`MarkHelp`, which adds a line of help; each reports the error
148+(`diag.Error`) and jumps to `recovery`, the parser's place to go on
149+from (see parse.pas). A message names what it found: `Found` describes
150+the current symbol and `SymText` spells an operator or reserved word,
151+so that the parser's `Expect` and `Expected` say `expected ";", found
152+"end"`. Errors in the text itself stop the
149153 compiler (`MarkBytes`, `LexError`): past a string left open, the
150154 symbols can't be trusted. There is no
151155 recovery: the first error ends the compilation. `SaveScan` and `RestoreScan` keep

src/diag.pas modified +2 -1

@@ -40,6 +40,7 @@
4040 procedure Error(const p: TPos; const msg: shortstring);
4141 procedure Warning(const p: TPos; const msg: shortstring);
4242 procedure Note(const p: TPos; const msg: shortstring);
43+function IntStr(n: int64): shortstring;
4344 procedure Help(const msg: shortstring);
4445 procedure Fatal(const msg: shortstring);
4546 procedure Finish;
@@ -113,7 +114,7 @@
113114 if colour then Paint := c + s + Plain else Paint := s;
114115 end;
115116
116-function IntStr(n: longint): shortstring;
117+function IntStr(n: int64): shortstring;
117118 var s: shortstring;
118119 begin
119120 Str(n, s);

src/gen.pas modified +66 -42

@@ -54,6 +54,7 @@
5454 n: longint;
5555 target: int64; { the frame slot of a procedure value, if any }
5656 chunk: longint; { else the procedure's chunk }
57+ obj: PObj; { the procedure called, if it has a name }
5758 code: boolean; { a code procedure: two results come in rax and rdx }
5859 ext: boolean; { C's: called through the chunk holding its address }
5960 isF: array[0..63] of boolean; { each argument: goes in an xmm register }
@@ -200,6 +201,20 @@
200201 SetData(x.chunk, @sbuf, slen + 1, 1);
201202 end;
202203
204+{ An item that is not a value, by what it is. }
205+procedure NotValue(const x: TItem);
206+begin
207+ case x.mode of
208+ mType: MarkAt(x.pos, TypeName(x.typ) + ' is a type, not a value');
209+ mBuiltin: MarkAt(x.pos, NameOf(x.obj^.name) + ' is a built-in procedure, not a value');
210+ mCase: MarkAt(x.pos, NameOf(x.obj^.name) + ' is a case, not a value');
211+ mNone:
212+ if x.obj <> nil then MarkAt(x.pos, NameOf(x.obj^.name) + ' returns nothing')
213+ else MarkAt(x.pos, 'the procedure returns nothing');
214+ else MarkAt(x.pos, 'a string can''t be an operand');
215+ end;
216+end;
217+
203218 procedure MakeItem(var x: TItem; o: PObj);
204219 begin
205220 FillChar(x, SizeOf(x), 0);
@@ -231,7 +246,7 @@
231246 oType: x.mode := mType;
232247 oBuiltin: x.mode := mBuiltin;
233248 oCase: x.mode := mCase;
234- else Mark('not a value');
249+ else Mark(NameOf(o^.name) + ' is not a value');
235250 end;
236251 end;
237252
@@ -309,7 +324,7 @@
309324
310325 procedure LoadVar(var x: TItem; r: longint);
311326 begin
312- if not IsScalar(x.typ) then MarkAt(x.pos, 'not a single value');
327+ if not IsScalar(x.typ) then MarkAt(x.pos, 'expected a single value, found ' + TypeName(x.typ));
313328 Load(r, MemOf(x, r), ScalarSize(x.typ), (x.typ^.form = fInt) and x.typ^.signed);
314329 end;
315330
@@ -335,7 +350,7 @@
335350 if x.obj^.ext then Load(RAX, MemRip(x.obj^.chunk, 0), 8, false)
336351 else Lea(RAX, MemRip(x.obj^.chunk, 0));
337352 end;
338- else MarkAt(x.pos, 'not a value');
353+ else NotValue(x);
339354 end;
340355 x.mode := mReg;
341356 end;
@@ -348,7 +363,7 @@
348363 m := MemOf(x, r);
349364 if (x.base <> bReg) or (x.reg <> r) or (x.off <> 0) then Lea(r, m);
350365 x.base := bReg; x.reg := r; x.off := 0;
351- end else MarkAt(x.pos, 'not a variable');
366+ end else MarkAt(x.pos, 'expected a variable');
352367 end;
353368
354369 procedure Save(var x: TItem);
@@ -465,11 +480,11 @@
465480 end else MarkAt(x.pos, 'can''t use a string as ' + TypeName(t));
466481 exit;
467482 end;
468- if x.mode in [mType, mBuiltin, mNone, mCase] then MarkAt(x.pos, 'not a value');
483+ if x.mode in [mType, mBuiltin, mNone, mCase] then NotValue(x);
469484 if Same(s, t) then exit;
470485 if (s = tRConst) and (t^.form = fReal) then RealTo(x, t)
471486 else if (s^.form = fConst) and (t^.form = fInt) then begin
472- if (x.mode = mConst) and not Fits(x.val, t) then MarkAt(x.pos, 'constant doesn''t fit ' + TypeName(t));
487+ if (x.mode = mConst) and not Fits(x.val, t) then MarkAt(x.pos, IntStr(x.val) + ' doesn''t fit ' + TypeName(t));
473488 x.typ := t;
474489 end else if (s^.form = fNil) and (t^.form in [fPtr, fProc, fError]) then
475490 x.typ := t
@@ -528,8 +543,8 @@
528543 var t: PType;
529544 begin
530545 t := x.typ;
531- if t^.form <> fPtr then MarkAt(x.pos, 'not a pointer');
532- if t^.base = nil then MarkAt(x.pos, 'pointer to an undeclared type');
546+ if t^.form <> fPtr then MarkAt(x.pos, 'expected a pointer, found ' + TypeName(t));
547+ if t^.base = nil then MarkAt(x.pos, TypeName(t) + ' points to a type never declared');
533548 Value(x);
534549 x.mode := mVar; x.base := bReg; x.reg := RAX; x.off := 0;
535550 x.typ := t^.base; x.vol := t^.vol; x.isVar := true;
@@ -550,7 +565,7 @@
550565 Value(x); PushRax; x.mode := mStack
551566 end else if (x.mode = mVar) and (x.typ^.form in [fArray, fSlice]) then
552567 Save(x)
553- else MarkAt(x.pos, 'not an array, slice or pointer');
568+ else MarkAt(x.pos, 'expected an array, a slice or a pointer, found ' + TypeName(x.typ));
554569 end;
555570
556571 procedure Index(var x, y: TItem);
@@ -558,7 +573,7 @@
558573 begin
559574 t := x.typ;
560575 s := t^.base^.size;
561- if not IsInt(y.typ) then MarkAt(y.pos, 'an index is an integer');
576+ if not IsInt(y.typ) then MarkAt(y.pos, 'an index is an integer, found ' + TypeName(y.typ));
562577 if t^.form = fPtr then begin
563578 Value(y);
564579 if s <> 1 then ImulI(RAX, s);
@@ -567,7 +582,7 @@
567582 x.mode := mVar; x.base := bReg; x.reg := RAX; x.off := 0;
568583 x.vol := t^.vol; x.isVar := true;
569584 end else if (t^.form = fArray) and (y.mode = mConst) then begin
570- if (y.val < 0) or (y.val >= t^.len) then MarkAt(y.pos, 'index out of range');
585+ if (y.val < 0) or (y.val >= t^.len) then MarkAt(y.pos, 'index ' + IntStr(y.val) + ' is out of range for a length of ' + IntStr(t^.len));
571586 x.off := x.off + y.val * s;
572587 if x.base = bStack then begin
573588 PopR(RAX); x.base := bReg; x.reg := RAX
@@ -596,7 +611,7 @@
596611
597612 procedure SliceLo(var lo: TItem);
598613 begin
599- if not IsInt(lo.typ) then MarkAt(lo.pos, 'an index is an integer');
614+ if not IsInt(lo.typ) then MarkAt(lo.pos, 'an index is an integer, found ' + TypeName(lo.typ));
600615 Value(lo);
601616 PushRax;
602617 end;
@@ -606,7 +621,7 @@
606621 begin
607622 t := x.typ;
608623 s := t^.base^.size;
609- if not IsInt(hi.typ) then MarkAt(hi.pos, 'an index is an integer');
624+ if not IsInt(hi.typ) then MarkAt(hi.pos, 'an index is an integer, found ' + TypeName(hi.typ));
610625 if x.vol then MarkAt(x.pos, 'can''t make a slice through a volatile pointer');
611626 Value(hi);
612627 MovRR(RDX, RAX);
@@ -661,7 +676,7 @@
661676 end else if IsInt(x.typ) then begin
662677 if x.mode = mConst then x.val := Cut(not x.val, x.typ)
663678 else begin Value(x); Unary(2, RAX); Norm(x.typ) end;
664- end else MarkAt(x.pos, 'not needs BOOL or an integer');
679+ end else MarkAt(x.pos, '"not" needs a BOOL or an integer, found ' + TypeName(x.typ));
665680 end;
666681
667682 function IsStrLike(t: PType): boolean;
@@ -699,7 +714,7 @@
699714 end else if (op in [sEql, sNeq]) and IsStrLike(x.typ) then
700715 StrSlice(x)
701716 else if x.mode in [mType, mBuiltin, mNone, mCase, mStr] then
702- MarkAt(x.pos, 'not a value')
717+ NotValue(x)
703718 else if x.mode <> mConst then begin
704719 Value(x); PushRax; x.mode := mStack
705720 end;
@@ -797,10 +812,10 @@
797812 xt, yt, t: PType; r: TItem; scale, sh, k: longint; isPtr, unsign, f: boolean; a, b: int64;
798813 begin
799814 xt := x.typ; yt := y.typ;
800- if y.mode in [mType, mBuiltin, mNone, mCase] then MarkAt(y.pos, 'not a value');
815+ if y.mode in [mType, mBuiltin, mNone, mCase] then NotValue(y);
801816
802817 if (op in [sAnd, sOr]) and (xt^.form = fBool) then begin
803- if yt^.form <> fBool then MarkAt(y.pos, 'and, or need two BOOLs');
818+ if yt^.form <> fBool then MarkAt(y.pos, SymText(op) + ' needs BOOLs, found ' + TypeName(yt));
804819 if (x.mode = mConst) and (y.mode = mConst) then begin
805820 FixLink(L);
806821 if op = sAnd then x.val := x.val and y.val else x.val := x.val or y.val;
@@ -830,47 +845,47 @@
830845 { the type of the result, and the checks }
831846 t := nil; scale := 1; isPtr := false;
832847 if IsInt(xt) and IsInt(yt) then begin
833- if op = sSlash then MarkAt(Join(x.pos, y.pos), '/ is for reals; integers use div');
848+ if op = sSlash then MarkHelp(Join(x.pos, y.pos), '"/" is for reals, found ' + TypeName(xt), 'integers divide with "div"');
834849 if op in [sShl, sShr] then begin
835850 if xt^.form = fConst then t := tConst else t := xt
836851 end else if (xt^.form = fConst) and (yt^.form = fConst) then t := tConst
837852 else if xt^.form = fConst then begin
838- if (x.mode = mConst) and not Fits(x.val, yt) then MarkAt(x.pos, 'constant doesn''t fit ' + TypeName(yt));
853+ if (x.mode = mConst) and not Fits(x.val, yt) then MarkAt(x.pos, IntStr(x.val) + ' doesn''t fit ' + TypeName(yt));
839854 t := yt
840855 end else if yt^.form = fConst then begin
841- if (y.mode = mConst) and not Fits(y.val, xt) then MarkAt(y.pos, 'constant doesn''t fit ' + TypeName(xt));
856+ if (y.mode = mConst) and not Fits(y.val, xt) then MarkAt(y.pos, IntStr(y.val) + ' doesn''t fit ' + TypeName(xt));
842857 t := xt
843858 end else if Same(xt, yt) then t := xt
844859 else MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt));
845860 end else if (xt^.form = fReal) and (yt^.form = fReal) then begin
846- if not (op in Rel + [sPlus, sMinus, sTimes, sSlash]) then MarkAt(Join(x.pos, y.pos), 'not a real operator');
861+ if not (op in Rel + [sPlus, sMinus, sTimes, sSlash]) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt));
847862 if xt = tRConst then t := yt
848863 else if (yt = tRConst) or Same(xt, yt) then t := xt
849864 else MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt));
850865 if (x.mode = mConst) and (x.typ <> t) then RealTo(x, t);
851866 if (y.mode = mConst) and (y.typ <> t) then RealTo(y, t);
852867 end else if (xt^.form = fBool) and (yt^.form = fBool) then begin
853- if not (op in [sXor, sEql, sNeq]) then MarkAt(Join(x.pos, y.pos), 'not a BOOL operator');
868+ if not (op in [sXor, sEql, sNeq]) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt));
854869 t := tBool;
855870 end else if (xt^.form = fPtr) and IsInt(yt) and (op in [sPlus, sMinus]) then begin
856871 t := xt; scale := xt^.base^.size; isPtr := true;
857872 if y.mode = mConst then y.typ := tI64;
858873 end else if (xt^.form = fPtr) and (yt^.form = fPtr) and (op = sMinus) then begin
859- if not Same(xt, yt) then MarkAt(Join(x.pos, y.pos), 'different pointer types');
874+ if not Same(xt, yt) then MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt));
860875 t := tI64; scale := xt^.base^.size; isPtr := true;
861876 end else if (xt^.form in [fPtr, fProc, fNil, fError]) and (yt^.form in [fPtr, fProc, fNil, fError]) then begin
862- if not (op in Rel) then MarkAt(Join(x.pos, y.pos), 'not a pointer operator');
877+ if not (op in Rel) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt));
863878 if (xt^.form in [fProc, fError]) or (yt^.form in [fProc, fError]) then
864- if not (op in [sEql, sNeq]) then MarkAt(Join(x.pos, y.pos), 'procedures and errors compare only with = and #');
879+ if not (op in [sEql, sNeq]) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt));
865880 if (xt^.form <> fNil) and (yt^.form <> fNil) and not Same(xt, yt) then
866881 if not ((xt^.form = fPtr) and (yt^.form = fPtr) and Same(xt^.base, yt^.base)) then
867- MarkAt(Join(x.pos, y.pos), 'different pointer types');
882+ MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt));
868883 t := tU64;
869884 end else if (xt^.form = fEnum) and Same(xt, yt) then begin
870- if not (op in Rel) then MarkAt(Join(x.pos, y.pos), 'enumerations only compare');
885+ if not (op in Rel) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt));
871886 t := xt;
872887 end else if (xt^.form = fSet) and Same(xt, yt) then begin
873- if not (op in [sPlus, sTimes, sMinus, sEql, sNeq, sLeq, sGeq]) then MarkAt(Join(x.pos, y.pos), 'not a set operator');
888+ if not (op in [sPlus, sTimes, sMinus, sEql, sNeq, sLeq, sGeq]) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt));
874889 t := xt;
875890 end else if (op = sIn) and (yt^.form = fSet) and Same(xt, yt^.base) then
876891 t := yt
@@ -881,7 +896,7 @@
881896 { constants }
882897 if (x.mode = mConst) and (y.mode = mConst) and not isPtr then begin
883898 if t^.form = fReal then begin
884- if not FoldReal(op, x, y, t, r) then MarkAt(Join(x.pos, y.pos), 'not a real operator');
899+ if not FoldReal(op, x, y, t, r) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt));
885900 x := r;
886901 end else if t^.form = fSet then begin
887902 a := x.val; b := y.val;
@@ -982,7 +997,7 @@
982997 sXor: Alu(aluXor, RAX, RCX);
983998 sShl: Shift(shShl, RAX);
984999 sShr: if unsign then Shift(shShr, RAX) else Shift(shSar, RAX);
985- else MarkAt(Join(x.pos, y.pos), 'not an operator for ' + TypeName(t));
1000+ else MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(t));
9861001 end;
9871002 Norm(t);
9881003 end;
@@ -994,14 +1009,17 @@
9941009 var s: PType; r: double; L1, L2: longint; f: boolean;
9951010 begin
9961011 s := x.typ;
997- if x.mode in [mType, mBuiltin, mNone, mCase, mStr] then MarkAt(x.pos, 'can''t convert this');
1012+ if x.mode in [mType, mBuiltin, mNone, mCase, mStr] then begin
1013+ if x.mode = mStr then MarkAt(x.pos, 'can''t convert a string');
1014+ NotValue(x);
1015+ end;
9981016 if Same(s, t) then exit;
9991017 if (IsInt(s) or (s^.form in [fEnum, fSet])) and (t^.form = fInt) then begin
10001018 if x.mode = mConst then x.val := Cut(x.val, t)
10011019 else begin Value(x); Norm(t) end;
10021020 end else if IsInt(s) and (t^.form = fEnum) then begin
10031021 if x.mode = mConst then begin
1004- if (x.val < 0) or (x.val >= t^.len) then MarkAt(x.pos, 'not a position of ' + TypeName(t))
1022+ if (x.val < 0) or (x.val >= t^.len) then MarkAt(x.pos, IntStr(x.val) + ' isn''t a position of ' + TypeName(t))
10051023 end else begin Value(x); CmpI(RAX, t^.len); Check(ccB) end;
10061024 end else if IsInt(s) and (t^.form = fSet) then begin
10071025 if x.mode = mConst then begin
@@ -1066,10 +1084,10 @@
10661084 begin
10671085 if x.mode = mProc then begin
10681086 c.sig := x.obj^.typ; c.chunk := x.obj^.chunk; c.target := 0;
1069- c.code := x.obj^.isCode; c.ext := x.obj^.ext;
1087+ c.obj := x.obj; c.code := x.obj^.isCode; c.ext := x.obj^.ext;
10701088 end else begin
1071- c.code := false; c.ext := false;
1072- if x.typ^.form <> fProc then MarkAt(x.pos, 'not a procedure');
1089+ c.obj := nil; c.code := false; c.ext := false;
1090+ if x.typ^.form <> fProc then MarkAt(x.pos, 'expected a procedure, found ' + TypeName(x.typ));
10731091 c.sig := x.typ; c.chunk := -1;
10741092 c.target := ToSlot(x);
10751093 end;
@@ -1086,7 +1104,10 @@
10861104 { past the parameters of a C procedure that ends in ...: a string
10871105 goes as a C string, an integer constant as an I64, a real
10881106 constant as an F64; C takes no F32 there }
1089- if not c.sig^.variadic then MarkAt(a.pos, 'too many arguments');
1107+ if not c.sig^.variadic then begin
1108+ if c.obj = nil then MarkAt(a.pos, 'too many arguments');
1109+ MarkAt(a.pos, 'too many arguments: ' + NameOf(c.obj^.name) + ' takes ' + IntStr(c.sig^.len));
1110+ end;
10901111 if a.mode = mStr then Coerce(a, tPtrU8)
10911112 else if a.typ^.form = fConst then Coerce(a, tI64)
10921113 else if a.typ = tRConst then Coerce(a, tReal)
@@ -1100,7 +1121,7 @@
11001121 c.isF[c.n] := (p^.typ^.form = fReal) and not p^.isVar;
11011122 if p^.isVar then begin
11021123 if (a.mode <> mVar) or not a.isVar then MarkAt(a.pos, 'a var parameter needs a variable');
1103- if not Same(a.typ, p^.typ) then MarkAt(a.pos, 'a var parameter needs exactly ' + TypeName(p^.typ));
1124+ if not Same(a.typ, p^.typ) then MarkAt(a.pos, 'a var parameter needs exactly ' + TypeName(p^.typ) + ', found ' + TypeName(a.typ));
11041125 if a.vol then MarkAt(a.pos, 'can''t pass through a volatile pointer to a var parameter');
11051126 Address(a, RAX);
11061127 s := AllocTemp(8, 8);
@@ -1125,7 +1146,10 @@
11251146 res: PType; i, ni, nf, k, pad: longint; ret: int64;
11261147 onStack: array[0..63] of boolean;
11271148 begin
1128- if c.param <> nil then Mark('too few arguments');
1149+ if c.param <> nil then begin
1150+ if c.obj = nil then Mark('too few arguments');
1151+ Mark('too few arguments: ' + NameOf(c.obj^.name) + ' takes ' + IntStr(c.sig^.len));
1152+ end;
11291153 res := c.sig^.base;
11301154 ret := 0;
11311155 ni := 0; nf := 0;
@@ -1169,7 +1193,7 @@
11691193 end;
11701194 FillChar(x, SizeOf(x), 0);
11711195 if res = nil then begin
1172- x.mode := mNone; x.typ := tNone
1196+ x.mode := mNone; x.typ := tNone; x.obj := c.obj
11731197 end else if ret <> 0 then
11741198 TempItem(x, res, ret)
11751199 else begin
@@ -1220,7 +1244,7 @@
12201244 var p: int64;
12211245 begin
12221246 if x.typ^.form = fEnum then exit(ToSlot(x));
1223- if (x.mode <> mVar) or (x.typ^.form <> fVariant) then MarkAt(x.pos, 'match needs a variant or an enumeration');
1247+ if (x.mode <> mVar) or (x.typ^.form <> fVariant) then MarkAt(x.pos, 'match needs a variant or an enumeration, found ' + TypeName(x.typ));
12241248 Address(x, RAX);
12251249 p := AllocTemp(8, 8);
12261250 Store(Mem(RBP, p), RAX, 8);
@@ -1265,7 +1289,7 @@
12651289
12661290 procedure CondJump(var x: TItem; var L: longint);
12671291 begin
1268- if x.typ^.form <> fBool then MarkAt(x.pos, 'a condition is a BOOL');
1292+ if x.typ^.form <> fBool then MarkAt(x.pos, 'a condition is a BOOL, found ' + TypeName(x.typ));
12691293 Value(x);
12701294 TestRR(RAX, RAX);
12711295 Jcc(ccE, L);
@@ -1435,7 +1459,7 @@
14351459
14361460 procedure ReturnNone;
14371461 begin
1438- if result <> nil then Mark('return needs a result');
1462+ if result <> nil then Mark('return needs a result of ' + TypeName(result));
14391463 Jmp(exitL);
14401464 end;
14411465

src/parse.pas modified +208 -167

@@ -54,6 +54,7 @@
5454 fwdTypes: array[0..255] of PType;
5555 fwdPos: array[0..255] of TPos; { where each names its type }
5656 numFwd: longint;
57+ lastCalled: PObj; { the procedure the last call was of, if it had a name }
5758 declExported: boolean; { the export mark of the declaration being read }
5859 curLoop: PLoop; { the innermost loop, or nil }
5960 defers: array[0..63] of longint; { the deferred statements in force }
@@ -76,9 +77,15 @@
7677
7778 { Little helpers }
7879
79-procedure Expect(s: TSym; const what: shortstring);
80+{ A missing symbol is reported just after the one before it. }
81+procedure Expected(const what: shortstring);
8082 begin
81- if tok <> s then MarkAt(MissingPos, what + ' expected');
83+ MarkAt(MissingPos, 'expected ' + what + ', found ' + Found);
84+end;
85+
86+procedure Expect(s: TSym);
87+begin
88+ if tok <> s then Expected(SymText(s));
8289 Next;
8390 end;
8491
@@ -89,7 +96,7 @@
8996
9097 procedure IdentDef(var n: longint; var exp: boolean);
9198 begin
92- if tok <> sIdent then MarkAt(MissingPos, 'name expected');
99+ if tok <> sIdent then Expected('a name');
93100 n := id;
94101 Next;
95102 exp := false;
@@ -228,7 +235,7 @@
228235
229236 function ConstValue(var x: TItem): int64;
230237 begin
231- if x.mode <> mConst then MarkAt(x.pos, 'constant expected');
238+ if x.mode <> mConst then MarkAt(x.pos, 'expected a constant');
232239 ConstValue := x.val;
233240 end;
234241
@@ -236,14 +243,14 @@
236243 var x: TItem;
237244 begin
238245 Expression(x, nil);
239- if not IsInt(x.typ) then MarkAt(x.pos, 'integer constant expected');
246+ if not IsInt(x.typ) then MarkAt(x.pos, 'expected an integer constant, found ' + TypeName(x.typ));
240247 ConstExpr := ConstValue(x);
241248 end;
242249
243250 function QualIdent: PObj;
244-var o: PObj;
251+var o: PObj; m: PModule;
245252 begin
246- if tok <> sIdent then MarkAt(MissingPos, 'name expected');
253+ if tok <> sIdent then Expected('a name');
247254 o := Lookup(id);
248255 if o = nil then begin
249256 Poison(id);
@@ -253,10 +260,11 @@
253260 if o^.typ = tPoison then quiet := true;
254261 Next;
255262 if o^.cls = oModule then begin
256- Expect(sPeriod, '.');
257- if tok <> sIdent then MarkAt(MissingPos, 'name expected');
258- o := Find(o^.module^.scope, id);
259- if (o = nil) or not o^.exported then Mark(NameOf(id) + ' isn''t exported');
263+ Expect(sPeriod);
264+ if tok <> sIdent then Expected('a name');
265+ m := o^.module;
266+ o := Find(m^.scope, id);
267+ if (o = nil) or not o^.exported then Mark(NameOf(id) + ' isn''t exported by ' + NameOf(m^.name));
260268 Next;
261269 end;
262270 QualIdent := o;
@@ -280,19 +288,19 @@
280288 begin
281289 t := NewType(fRecord, 0, 1);
282290 if tok = sPacked then begin t^.packd := true; Next end;
283- Expect(sRecord, 'record');
291+ Expect(sRecord);
284292 t^.scope := NewScope;
285293 off := 0; maxA := 1; last := nil;
286294 while tok = sIdent do begin
287295 n := 0;
288296 repeat
289- if n > High(names) then Mark('too many names');
297+ if n > High(names) then Mark('more than ' + IntStr(High(names) + 1) + ' names in one declaration');
290298 IdentDef(names[n], exps[n]);
291299 inc(n);
292300 if tok <> sComma then break;
293301 Next;
294302 until false;
295- Expect(sColon, ':');
303+ Expect(sColon);
296304 ft := ParseType;
297305 if t^.packd then a := 1 else a := ft^.align;
298306 for i := 0 to n - 1 do begin
@@ -306,9 +314,9 @@
306314 off := off + ft^.size;
307315 end;
308316 if a > maxA then maxA := a;
309- Expect(sSemicolon, ';');
317+ Expect(sSemicolon);
310318 end;
311- Expect(sEnd, 'end');
319+ Expect(sEnd);
312320 t^.align := maxA;
313321 t^.size := AlignUp(off, maxA);
314322 RecordType := t;
@@ -317,7 +325,7 @@
317325 function VariantType: PType;
318326 var t, ft: PType; c, lastC, f, lastF: PObj; tag, off, maxSize: int64; n: longint;
319327 begin
320- Expect(sVariant, 'variant');
328+ Expect(sVariant);
321329 t := NewType(fVariant, 8, 8);
322330 tag := 0; maxSize := 8; lastC := nil;
323331 while tok = sIdent do begin
@@ -335,7 +343,7 @@
335343 repeat
336344 n := 0;
337345 repeat
338- if tok <> sIdent then MarkAt(MissingPos, 'name expected');
346+ if tok <> sIdent then Expected('a name');
339347 f := NewObj(oField, id, nil);
340348 f^.exported := true;
341349 if lastF = nil then c^.fields := f else lastF^.next := f;
@@ -345,7 +353,7 @@
345353 if tok <> sComma then break;
346354 Next;
347355 until false;
348- Expect(sColon, ':');
356+ Expect(sColon);
349357 ft := ParseType;
350358 f := c^.fields;
351359 while f^.typ <> nil do f := f^.next;
@@ -360,13 +368,13 @@
360368 if tok <> sSemicolon then break;
361369 Next;
362370 until false;
363- Expect(sRparen, ')');
371+ Expect(sRparen);
364372 end;
365373 if off > maxSize then maxSize := off;
366- Expect(sSemicolon, ';');
374+ Expect(sSemicolon);
367375 inc(tag);
368376 end;
369- Expect(sEnd, 'end');
377+ Expect(sEnd);
370378 t^.len := tag;
371379 t^.size := AlignUp(maxSize, t^.align);
372380 VariantType := t;
@@ -394,7 +402,7 @@
394402 if tok <> sComma then break;
395403 Next;
396404 until false;
397- Expect(sRparen, ')');
405+ Expect(sRparen);
398406 t^.size := AlignUp(off, t^.align);
399407 if t^.len = 1 then Results := t^.fields^.typ else Results := t;
400408 end;
@@ -417,7 +425,7 @@
417425 if isVar then Next;
418426 first := nil;
419427 repeat
420- if tok <> sIdent then MarkAt(MissingPos, 'name expected');
428+ if tok <> sIdent then Expected('a name');
421429 p := NewObj(oVar, id, nil);
422430 p^.isVar := isVar;
423431 p^.lev := 1;
@@ -429,13 +437,13 @@
429437 if tok <> sComma then break;
430438 Next;
431439 until false;
432- Expect(sColon, ':');
440+ Expect(sColon);
433441 pt := ParseType;
434442 while first <> nil do begin first^.typ := pt; first := first^.next end;
435443 if tok <> sSemicolon then break;
436444 Next;
437445 until false;
438- Expect(sRparen, ')');
446+ Expect(sRparen);
439447 end;
440448 t^.len := n;
441449 if tok = sColon then begin
@@ -453,7 +461,7 @@
453461 last := nil;
454462 repeat
455463 Next;
456- if tok <> sIdent then MarkAt(MissingPos, 'name expected');
464+ if tok <> sIdent then Expected('a name');
457465 o := NewObj(oConst, id, t);
458466 o^.val := t^.len;
459467 o^.exported := declExported;
@@ -463,15 +471,15 @@
463471 inc(t^.len);
464472 Next;
465473 until tok <> sComma;
466- Expect(sRparen, ')');
467- if t^.len > 256 then MarkAt(SpanFrom(start), 'more than 256 names');
474+ Expect(sRparen);
475+ if t^.len > 256 then MarkAt(SpanFrom(start), 'an enumeration has at most 256 names');
468476 EnumType := t;
469477 end;
470478
471479 function SetOf(e: PType; const at: TPos): PType;
472480 var t: PType;
473481 begin
474- if (e^.form <> fEnum) or (e^.len > 64) then MarkAt(at, 'a set is of an enumeration of at most 64 names');
482+ if (e^.form <> fEnum) or (e^.len > 64) then MarkAt(at, 'a set needs an enumeration of at most 64 names, found ' + TypeName(e));
475483 t := NewType(fSet, 8, 8);
476484 if e^.len <= 8 then t^.size := 1
477485 else if e^.len <= 16 then t^.size := 2
@@ -489,7 +497,7 @@
489497 case tok of
490498 sIdent: begin
491499 o := QualIdent;
492- if o^.cls <> oType then MarkAt(SpanFrom(start), 'type expected');
500+ if o^.cls <> oType then MarkAt(SpanFrom(start), NameOf(o^.name) + ' isn''t a type');
493501 t := o^.typ;
494502 end;
495503 sLbrak: begin
@@ -501,8 +509,8 @@
501509 end else begin
502510 start := TokPos;
503511 n := ConstExpr;
504- if (n <= 0) or (n > (int64(1) shl 40)) then MarkAt(SpanFrom(start), 'bad array length');
505- Expect(sRbrak, ']');
512+ if (n <= 0) or (n > (int64(1) shl 40)) then MarkAt(SpanFrom(start), 'an array''s length is from 1 to 2^40, found ' + IntStr(n));
513+ Expect(sRbrak);
506514 t := NewType(fArray, 0, 1);
507515 t^.len := n;
508516 t^.base := ParseType();
@@ -518,7 +526,7 @@
518526 { a type declared later in this section }
519527 t := NewPtr(nil, vol);
520528 t^.fwd := id;
521- if numFwd > High(fwdTypes) then Mark('too many forward pointers');
529+ if numFwd > High(fwdTypes) then Mark('more than ' + IntStr(High(fwdTypes) + 1) + ' pointers to types not yet declared');
522530 fwdTypes[numFwd] := t;
523531 fwdPos[numFwd] := TokPos;
524532 inc(numFwd);
@@ -532,11 +540,11 @@
532540 sLparen: t := EnumType;
533541 sSet: begin
534542 Next;
535- Expect(sOf, 'of');
543+ Expect(sOf);
536544 start := TokPos;
537545 t := SetOf(ParseType(), start);
538546 end;
539- else MarkAt(MissingPos, 'type expected');
547+ else Expected('a type');
540548 end;
541549 ParseType := t;
542550 end;
@@ -547,7 +555,7 @@
547555 var c: TCall; a: TItem; want: PType;
548556 begin
549557 BeginCall(c, x);
550- Expect(sLparen, '(');
558+ Expect(sLparen);
551559 if tok <> sRparen then
552560 repeat
553561 if c.param <> nil then want := c.param^.typ else want := nil;
@@ -556,7 +564,7 @@
556564 if tok <> sComma then break;
557565 Next;
558566 until false;
559- Expect(sRparen, ')');
567+ Expect(sRparen);
560568 EndCall(c, x);
561569 end;
562570
@@ -564,9 +572,9 @@
564572 var i: longint; a: TItem;
565573 begin
566574 for i := 0 to n - 1 do begin
567- if i > 0 then Expect(sComma, ',');
575+ if i > 0 then Expect(sComma);
568576 Expression(a, nil);
569- if not (IsScalar(a.typ) and (a.typ^.form <> fReal)) then MarkAt(a.pos, 'integer or pointer expected');
577+ if not (IsScalar(a.typ) and (a.typ^.form <> fReal)) then MarkAt(a.pos, 'expected an integer or a pointer, found ' + TypeName(a.typ));
570578 if a.typ^.form = fConst then Coerce(a, tI64);
571579 slots[i] := ToSlot(a);
572580 end;
@@ -576,14 +584,14 @@
576584 var p, a: TItem; t: PType; s: array[0..2] of int64; i, n: longint;
577585 begin
578586 Expression(p, nil);
579- if p.typ^.form <> fPtr then MarkAt(p.pos, 'a pointer expected');
587+ if p.typ^.form <> fPtr then MarkAt(p.pos, 'expected a pointer, found ' + TypeName(p.typ));
580588 t := p.typ^.base;
581589 if not (((t^.form = fInt) or ((t^.form = fPtr) and (which <> bXadd))) and (t^.size = 8)) then
582- MarkAt(p.pos, 'an 8-byte integer or pointer expected');
590+ MarkAt(p.pos, 'expected an 8-byte integer or a pointer, found ' + TypeName(t));
583591 s[0] := ToSlot(p);
584592 if which = bCas then n := 2 else n := 1;
585593 for i := 1 to n do begin
586- Expect(sComma, ',');
594+ Expect(sComma);
587595 Expression(a, t);
588596 Coerce(a, t);
589597 s[i] := ToSlot(a);
@@ -613,11 +621,11 @@
613621 if (x.mode <> mVar) or not x.isVar or (x.typ^.form <> fPtr) then MarkAt(x.pos, 'NEW needs a pointer variable');
614622 t := x.typ^.base;
615623 Save(x);
616- Expect(sComma, ',');
624+ Expect(sComma);
617625 Expression(y, nil);
618626 if (y.typ^.form <> fPtr) or (y.typ^.base^.obj = nil) or (y.typ^.base^.obj^.module = nil)
619627 or (NameOf(y.typ^.base^.obj^.name) <> 'Allocator')
620- or (NameOf(y.typ^.base^.obj^.module^.name) <> 'Mem') then MarkAt(y.pos, 'NEW needs a ^Mem.Allocator');
628+ or (NameOf(y.typ^.base^.obj^.module^.name) <> 'Mem') then MarkAt(y.pos, 'NEW needs a ^Mem.Allocator, found ' + TypeName(y.typ));
621629 f := Find(y.typ^.base^.scope, Name('alloc'));
622630 s := ToSlot(y);
623631 Load(RAX, Mem(RBP, s), 8, false);
@@ -649,13 +657,18 @@
649657 x.mode := mNone;
650658 end;
651659
660+function IncOrDec(which: longint): shortstring;
661+begin
662+ if which = bDec then IncOrDec := 'DEC' else IncOrDec := 'INC';
663+end;
664+
652665 procedure Builtin(var x: TItem);
653666 const SysRegs: array[0..6] of longint = (RAX, RDI, RSI, RDX, R10, R8, R9);
654667 var which, n, i: longint; y: TItem; t: PType; slots: array[0..6] of int64;
655668 begin
656669 which := x.obj^.val;
657670 if which in [bFence, bArgc, bArgv] then begin
658- if tok = sLparen then begin Next; Expect(sRparen, ')') end;
671+ if tok = sLparen then begin Next; Expect(sRparen) end;
659672 MakeConst(x, tNone, 0);
660673 case which of
661674 bFence: begin Mfence; x.mode := mNone end;
@@ -664,7 +677,7 @@
664677 end;
665678 exit;
666679 end;
667- Expect(sLparen, '(');
680+ Expect(sLparen);
668681 case which of
669682 bSize: begin
670683 t := ParseType;
@@ -687,7 +700,7 @@
687700 Load(RAX, Mem(RAX, 8), 8, false);
688701 MakeConst(x, tI64, 0);
689702 x.mode := mReg;
690- end else MarkAt(y.pos, 'LEN needs an array or slice');
703+ end else MarkAt(y.pos, 'LEN needs an array or a slice, found ' + TypeName(y.typ));
691704 end;
692705 bSyscall: begin
693706 n := 1;
@@ -695,7 +708,7 @@
695708 while (tok = sComma) and (n < 7) do begin
696709 Next;
697710 Expression(y, nil);
698- if not (IsScalar(y.typ) and (y.typ^.form <> fReal)) then MarkAt(y.pos, 'integer or pointer expected');
711+ if not (IsScalar(y.typ) and (y.typ^.form <> fReal)) then MarkAt(y.pos, 'expected an integer or a pointer, found ' + TypeName(y.typ));
699712 if y.typ^.form = fConst then Coerce(y, tI64);
700713 slots[n] := ToSlot(y);
701714 inc(n);
@@ -710,7 +723,7 @@
710723 bInc, bDec: begin
711724 Expression(x, nil);
712725 if (x.mode <> mVar) or not x.isVar or (x.typ^.form <> fInt) then
713- MarkAt(x.pos, 'INC and DEC need an integer variable');
726+ MarkAt(x.pos, IncOrDec(which) + ' needs an integer variable');
714727 Save(x);
715728 if tok = sComma then begin
716729 Next;
@@ -722,7 +735,7 @@
722735 end;
723736 bNew: New_(x);
724737 end;
725- Expect(sRparen, ')');
738+ Expect(sRparen);
726739 end;
727740
728741 procedure ConstructCase(var x: TItem; c: PObj; const at: TPos);
@@ -736,9 +749,9 @@
736749 Expression(a, f^.typ);
737750 SetField(x, f, a);
738751 f := f^.next;
739- if f <> nil then Expect(sComma, ',');
752+ if f <> nil then Expect(sComma);
740753 end;
741- Expect(sRparen, ')');
754+ Expect(sRparen);
742755 end else if f <> nil then MarkAt(at, NameOf(c^.name) + ' needs its fields');
743756 end;
744757
@@ -750,7 +763,7 @@
750763 start := TokPos;
751764 o := QualIdent;
752765 called := false;
753- if o^.cls = oModule then MarkAt(SpanFrom(start), 'a module is not a value');
766+ if o^.cls = oModule then MarkAt(SpanFrom(start), NameOf(o^.name) + ' is a module, not a value');
754767 MakeItem(x, o);
755768 if x.mode = mBuiltin then begin
756769 Builtin(x);
@@ -763,12 +776,12 @@
763776 case tok of
764777 sPeriod: begin
765778 Next;
766- if (x.mode <> mVar) or (x.typ^.form <> fRecord) then MarkAt(x.pos, 'not a record');
767- if tok <> sIdent then MarkAt(MissingPos, 'field expected');
779+ if (x.mode <> mVar) or (x.typ^.form <> fRecord) then MarkAt(x.pos, 'expected a record, found ' + TypeName(x.typ));
780+ if tok <> sIdent then Expected('a field');
768781 f := Find(x.typ^.scope, id);
769- if f = nil then Mark('no field ' + NameOf(id));
782+ if f = nil then Mark(TypeName(x.typ) + ' has no field ' + NameOf(id));
770783 if not f^.exported and (x.typ^.module <> curModule) then
771- Mark('field ' + NameOf(id) + ' isn''t exported');
784+ Mark('field ' + NameOf(id) + ' of ' + TypeName(x.typ) + ' isn''t exported');
772785 Next;
773786 Field(x, f);
774787 called := false;
@@ -784,7 +797,7 @@
784797 Expression(z, nil);
785798 Slice(x, y, z);
786799 end else Index(x, y);
787- Expect(sRbrak, ']');
800+ Expect(sRbrak);
788801 called := false;
789802 end;
790803 sLparen: begin
@@ -792,9 +805,10 @@
792805 t := x.typ;
793806 Next;
794807 Expression(x, nil);
795- Expect(sRparen, ')');
808+ Expect(sRparen);
796809 Convert(x, t);
797810 end else begin
811+ if x.mode = mProc then lastCalled := x.obj else lastCalled := nil;
798812 Call(x);
799813 called := true;
800814 end;
@@ -819,7 +833,7 @@
819833 n := 0;
820834 if tok <> sRbrak then
821835 repeat
822- if n > High(slots) then Mark('too many elements');
836+ if n > High(slots) then Mark('more than ' + IntStr(High(slots) + 1) + ' elements');
823837 Expression(e, et);
824838 Coerce(e, et);
825839 if IsScalar(et) then slots[n] := ToSlot(e)
@@ -831,8 +845,8 @@
831845 if tok <> sComma then break;
832846 Next;
833847 until false;
834- Expect(sRbrak, ']');
835- if (want^.form = fArray) and (n <> want^.len) then MarkAt(SpanFrom(start), 'wrong number of elements');
848+ Expect(sRbrak);
849+ if (want^.form = fArray) and (n <> want^.len) then MarkAt(SpanFrom(start), 'expected ' + IntStr(want^.len) + ' elements, found ' + IntStr(n));
836850 if n = 0 then begin
837851 MovRI(RAX, 0);
838852 SliceOf(x, want, 0);
@@ -870,40 +884,44 @@
870884 n := 0;
871885 if tok <> sRbrace then
872886 repeat
873- if tok <> sIdent then MarkAt(MissingPos, 'field expected');
887+ if tok <> sIdent then Expected('a field');
874888 f := Find(t^.scope, id);
875- if f = nil then Mark('no field ' + NameOf(id));
876- if not f^.exported and (t^.module <> curModule) then Mark('field ' + NameOf(id) + ' isn''t exported');
877- for i := 0 to n - 1 do if seen[i] = id then Mark(NameOf(id) + ' twice');
889+ if f = nil then Mark(TypeName(t) + ' has no field ' + NameOf(id));
890+ if not f^.exported and (t^.module <> curModule) then
891+ Mark('field ' + NameOf(id) + ' of ' + TypeName(t) + ' isn''t exported');
892+ for i := 0 to n - 1 do if seen[i] = id then Mark('field ' + NameOf(id) + ' is given twice');
878893 if n <= High(seen) then begin seen[n] := id; inc(n) end;
879894 Next;
880- Expect(sColon, ':');
895+ Expect(sColon);
881896 Expression(a, f^.typ);
882897 SetField(x, f, a);
883898 if tok <> sComma then break;
884899 Next;
885900 until false;
886- Expect(sRbrace, '}');
901+ Expect(sRbrace);
887902 end;
888903
889904 { A set literal: the bits of the constant names, or'd at run time with
890905 those of the others. }
891906 procedure SetLiteral(var x: TItem; t: PType);
892-var e: TItem; bits, slot: int64; start: TPos;
907+var e: TItem; bits, slot: int64; start: TPos; s: shortstring;
893908 begin
894909 start := TokPos;
895910 Next;
896- if (t <> nil) and (t^.form <> fSet) then MarkAt(SpanFrom(start), 'a set literal needs a set type');
911+ if (t <> nil) and (t^.form <> fSet) then MarkAt(SpanFrom(start), 'expected a set type, found ' + TypeName(t));
897912 bits := 0;
898913 slot := 0;
899914 if tok <> sRbrace then
900915 repeat
901916 if t = nil then Expression(e, nil) else Expression(e, t^.base);
902917 if t = nil then begin
903- if e.typ^.form <> fEnum then MarkAt(e.pos, 'a set holds names of an enumeration');
918+ if e.typ^.form <> fEnum then MarkAt(e.pos, 'a set holds names of an enumeration, found ' + TypeName(e.typ));
904919 t := SetOf(e.typ, e.pos);
905920 end;
906- if not Same(e.typ, t^.base) then MarkAt(e.pos, 'not a name of ' + TypeName(t^.base));
921+ if not Same(e.typ, t^.base) then begin
922+ if e.obj <> nil then s := NameOf(e.obj^.name) else s := TypeName(e.typ);
923+ MarkAt(e.pos, s + ' isn''t a name of ' + TypeName(t^.base));
924+ end;
907925 if e.mode = mConst then bits := bits or (int64(1) shl e.val)
908926 else begin
909927 if slot = 0 then begin
@@ -921,7 +939,7 @@
921939 if tok <> sComma then break;
922940 Next;
923941 until false;
924- Expect(sRbrace, '}');
942+ Expect(sRbrace);
925943 if t = nil then MarkAt(SpanFrom(start), '{} needs a known set type');
926944 MakeConst(x, t, bits);
927945 if slot <> 0 then begin
@@ -933,7 +951,7 @@
933951 end;
934952
935953 procedure Factor(var x: TItem; want: PType);
936-var called, vol: boolean; t: PType; start: TPos;
954+var called, vol: boolean; t: PType; start: TPos; s: shortstring;
937955 begin
938956 start := TokPos;
939957 case tok of
@@ -946,10 +964,16 @@
946964 sString: begin MakeStr(x); Next end;
947965 sIdent: begin
948966 Designator(x, called);
949- if x.mode = mNone then MarkAt(x.pos, 'this procedure returns nothing');
950- if x.typ^.tuple then MarkAt(x.pos, 'several results go only to a, b := ...');
967+ if x.mode = mNone then begin
968+ if lastCalled <> nil then s := NameOf(lastCalled^.name) else s := 'this procedure';
969+ MarkAt(x.pos, s + ' returns nothing');
970+ end;
971+ if x.typ^.tuple then begin
972+ if lastCalled <> nil then s := NameOf(lastCalled^.name) else s := 'this procedure';
973+ MarkHelp(x.pos, s + ' returns several results', 'they go to variables: a, b := ' + s + '(...)');
974+ end;
951975 end;
952- sLparen: begin Next; Expression(x, want); Expect(sRparen, ')') end;
976+ sLparen: begin Next; Expression(x, want); Expect(sRparen) end;
953977 sNot: begin Next; Factor(x, nil); NotOp(x) end;
954978 sLbrak: ArrayLiteral(x, want);
955979 sLbrace: if (want <> nil) and (want^.form = fRecord) then RecordLiteral(x, want)
@@ -959,12 +983,12 @@
959983 vol := tok = sVolatile;
960984 if vol then Next;
961985 t := NewPtr(ParseType, vol);
962- Expect(sLparen, '(');
986+ Expect(sLparen);
963987 Expression(x, nil);
964- Expect(sRparen, ')');
988+ Expect(sRparen);
965989 Convert(x, t);
966990 end;
967- else MarkAt(MissingPos, 'expression expected');
991+ else Expected('an expression');
968992 end;
969993 x.pos := SpanFrom(start);
970994 end;
@@ -1040,7 +1064,7 @@
10401064 begin
10411065 Next;
10421066 Expression(x, nil);
1043- Expect(sThen, 'then');
1067+ Expect(sThen);
10441068 L := NoLabel;
10451069 CondJump(x, L);
10461070 Statements;
@@ -1050,7 +1074,7 @@
10501074 FixLink(L);
10511075 Next;
10521076 Expression(x, nil);
1053- Expect(sThen, 'then');
1077+ Expect(sThen);
10541078 L := NoLabel;
10551079 CondJump(x, L);
10561080 Statements;
@@ -1061,7 +1085,7 @@
10611085 Next;
10621086 Statements;
10631087 end else FixLink(L);
1064- Expect(sEnd, 'end');
1088+ Expect(sEnd);
10651089 FixLink(endL);
10661090 end;
10671091
@@ -1071,13 +1095,13 @@
10711095 Next;
10721096 top := pc;
10731097 Expression(x, nil);
1074- Expect(sDo, 'do');
1098+ Expect(sDo);
10751099 L := NoLabel;
10761100 CondJump(x, L);
10771101 Loop(lp, old);
10781102 Statements;
10791103 JmpBack(top);
1080- Expect(sEnd, 'end');
1104+ Expect(sEnd);
10811105 FixLink(L);
10821106 FixLink(lp.brk);
10831107 curLoop := old;
@@ -1091,7 +1115,7 @@
10911115 Loop(lp, old);
10921116 Statements;
10931117 curLoop := old;
1094- Expect(sUntil, 'until');
1118+ Expect(sUntil);
10951119 Expression(x, nil);
10961120 L := NoLabel;
10971121 CondJump(x, L);
@@ -1105,17 +1129,20 @@
11051129 lp: TLoop; old: PLoop;
11061130 begin
11071131 Next;
1108- if tok <> sIdent then MarkAt(MissingPos, 'name expected');
1132+ if tok <> sIdent then Expected('a name');
11091133 o := Lookup(id);
1110- if (o = nil) or (o^.cls <> oVar) or not (o^.typ^.form in [fInt, fEnum]) then
1111- Mark('a for loop needs an integer or enumeration variable');
1134+ if o = nil then Mark(NameOf(id) + ' isn''t declared');
1135+ if (o^.cls <> oVar) or not (o^.typ^.form in [fInt, fEnum]) then
1136+ if o^.cls = oVar then
1137+ Mark('a for loop needs an integer or enumeration variable, found ' + TypeName(o^.typ))
1138+ else Mark(NameOf(id) + ' isn''t a variable');
11121139 Next;
1113- Expect(sBecomes, ':=');
1140+ Expect(sBecomes);
11141141 MakeItem(v, o);
11151142 Save(v);
11161143 Expression(a, o^.typ);
11171144 Assign(v, a);
1118- Expect(sTo, 'to');
1145+ Expect(sTo);
11191146 Expression(b, o^.typ);
11201147 Coerce(b, o^.typ);
11211148 bslot := ToSlot(b);
@@ -1126,7 +1153,7 @@
11261153 step := ConstValue(s);
11271154 if step = 0 then MarkAt(s.pos, 'the step can''t be zero');
11281155 end;
1129- Expect(sDo, 'do');
1156+ Expect(sDo);
11301157 exitL := NoLabel;
11311158 top := pc;
11321159 MakeItem(v, o);
@@ -1141,7 +1168,7 @@
11411168 Loop(lp, old);
11421169 Statements;
11431170 curLoop := old;
1144- Expect(sEnd, 'end');
1171+ Expect(sEnd);
11451172 ForNext(o, bslot, step, exitL, top);
11461173 FixLink(exitL);
11471174 FixLink(lp.brk);
@@ -1156,7 +1183,7 @@
11561183 Expression(x, nil);
11571184 p := MatchBegin(x);
11581185 t := x.typ;
1159- Expect(sOf, 'of');
1186+ Expect(sOf);
11601187 FillChar(seen, SizeOf(seen), 0);
11611188 hasElse := false;
11621189 endL := NoLabel;
@@ -1165,15 +1192,15 @@
11651192 if hasElse then Mark('else must be the last arm');
11661193 if tok = sElse then begin
11671194 Next;
1168- Expect(sColon, ':');
1195+ Expect(sColon);
11691196 Statements;
11701197 hasElse := true;
11711198 end else begin
1172- if tok <> sIdent then MarkAt(MissingPos, 'case expected');
1199+ if tok <> sIdent then Expected('a case');
11731200 c := t^.fields;
11741201 while (c <> nil) and (c^.name <> id) do c := c^.next;
11751202 if c = nil then Mark(NameOf(id) + ' isn''t a case of ' + TypeName(t));
1176- if (c^.val <= High(seen)) and seen[c^.val] then Mark('case twice');
1203+ if (c^.val <= High(seen)) and seen[c^.val] then Mark(NameOf(c^.name) + ' has two arms');
11771204 if c^.val <= High(seen) then seen[c^.val] := true;
11781205 Next;
11791206 L := NoLabel;
@@ -1184,8 +1211,8 @@
11841211 f := c^.fields;
11851212 n := 0;
11861213 repeat
1187- if tok <> sIdent then MarkAt(MissingPos, 'name expected');
1188- if f = nil then Mark('too many fields');
1214+ if tok <> sIdent then Expected('a name');
1215+ if f = nil then Mark('more names than ' + NameOf(c^.name) + ' has fields');
11891216 o := NewObj(oVar, id, f^.typ);
11901217 o^.lev := 1; o^.ind := true; o^.isVar := true;
11911218 o^.val := p; o^.off := f^.val;
@@ -1196,10 +1223,10 @@
11961223 if tok <> sComma then break;
11971224 Next;
11981225 until false;
1199- if f <> nil then Mark('name all the fields, or none');
1200- Expect(sRparen, ')');
1226+ if f <> nil then Mark('name all the fields of ' + NameOf(c^.name) + ', or none');
1227+ Expect(sRparen);
12011228 end;
1202- Expect(sColon, ':');
1229+ Expect(sColon);
12031230 Statements;
12041231 CloseScope;
12051232 Jmp(endL);
@@ -1207,7 +1234,7 @@
12071234 end;
12081235 end;
12091236 endAt := TokPos;
1210- Expect(sEnd, 'end');
1237+ Expect(sEnd);
12111238 if not hasElse then begin
12121239 c := t^.fields;
12131240 while c <> nil do begin
@@ -1218,26 +1245,37 @@
12181245 FixLink(endL);
12191246 end;
12201247
1248+{ What a message calls x: its name n when x is just that name, else what
1249+ it is. }
1250+function Subject(const x: TItem; n: longint): shortstring;
1251+begin
1252+ if x.pos.b - x.pos.a = length(NameOf(n)) then Subject := NameOf(n)
1253+ else if x.mode = mConst then Subject := 'a constant'
1254+ else Subject := 'a value';
1255+end;
1256+
12211257 { a, b := f(x): the variables first, left to right, then the call;
12221258 then each result to its variable, in order. }
1223-procedure MultiAssign(var x: TItem);
1224-var d: array[0..15] of TItem; y, z: TItem; n, i: longint; called: boolean; f: PObj;
1259+procedure MultiAssign(var x: TItem; first: longint);
1260+var d: array[0..15] of TItem; dn: array[0..15] of longint; y, z: TItem; n, i: longint; called: boolean; f: PObj;
12251261 begin
12261262 n := 0;
12271263 d[0] := x;
1264+ dn[0] := first;
12281265 repeat
1229- if (d[n].mode <> mVar) or not d[n].isVar then MarkAt(d[n].pos, 'can''t assign to this');
1266+ if (d[n].mode <> mVar) or not d[n].isVar then MarkAt(d[n].pos, 'can''t assign to ' + Subject(d[n], dn[n]));
12301267 Pin(d[n]);
12311268 inc(n);
12321269 if tok <> sComma then break;
1233- if n > High(d) then Mark('too many variables');
1270+ if n > High(d) then Mark('more than ' + IntStr(High(d) + 1) + ' variables in one assignment');
12341271 Next;
1272+ dn[n] := id;
12351273 Designator(d[n], called);
12361274 until false;
1237- Expect(sBecomes, ':=');
1275+ Expect(sBecomes);
12381276 Designator(y, called);
12391277 if not called or not y.typ^.tuple or (y.typ^.len <> n) then
1240- MarkAt(y.pos, 'needs a call with as many results as variables');
1278+ MarkAt(y.pos, 'expected a call with ' + IntStr(n) + ' results');
12411279 f := y.typ^.fields;
12421280 for i := 0 to n - 1 do begin
12431281 z := y;
@@ -1255,7 +1293,7 @@
12551293 Expression(x, f^.typ);
12561294 ReturnField(f, x);
12571295 f := f^.next;
1258- if f <> nil then Expect(sComma, ',');
1296+ if f <> nil then Expect(sComma);
12591297 end;
12601298 end;
12611299
@@ -1267,7 +1305,7 @@
12671305 start := TokPos;
12681306 Next;
12691307 if directDefer then MarkAt(SpanFrom(start), 'defer can''t be deferred');
1270- if numDefers > High(defers) then MarkAt(SpanFrom(start), 'too many deferred statements');
1308+ if numDefers > High(defers) then MarkAt(SpanFrom(start), 'more than ' + IntStr(High(defers) + 1) + ' deferred statements in one procedure');
12711309 L := NoLabel;
12721310 Jmp(L);
12731311 pos := pc;
@@ -1287,27 +1325,28 @@
12871325 end;
12881326
12891327 procedure OneStatement;
1290-var x, y: TItem; called: boolean; m: int64; c: TCall; start: TPos;
1328+var x, y: TItem; called: boolean; m: int64; c: TCall; start: TPos; first: longint;
12911329 begin
12921330 start := TokPos;
1331+ first := id;
12931332 NoteLine(CurLine);
12941333 m := TempMark;
12951334 case tok of
12961335 sIdent: begin
12971336 Designator(x, called);
12981337 if tok = sBecomes then begin
1299- if (x.mode <> mVar) or not x.isVar then MarkAt(x.pos, 'can''t assign to this');
1338+ if (x.mode <> mVar) or not x.isVar then MarkAt(x.pos, 'can''t assign to ' + Subject(x, first));
13001339 Save(x);
13011340 Next;
13021341 Expression(y, x.typ);
13031342 Assign(x, y);
13041343 end else if tok = sComma then
1305- MultiAssign(x)
1344+ MultiAssign(x, first)
13061345 else if not called then begin
13071346 if (x.mode = mProc) or ((x.mode in [mVar, mReg]) and (x.typ^.form = fProc)) then begin
13081347 BeginCall(c, x);
13091348 EndCall(c, x);
1310- end else MarkAt(x.pos, 'not a statement');
1349+ end else MarkAt(x.pos, Subject(x, first) + ' isn''t a statement');
13111350 end;
13121351 end;
13131352 sIf: IfStatement;
@@ -1343,8 +1382,8 @@
13431382 Jmp(curLoop^.brk);
13441383 end;
13451384 sDefer: Defer;
1346- else if AtLineStart then MarkAt(MissingPos, 'end expected')
1347- else MarkAt(MissingPos, 'statement expected');
1385+ else if AtLineStart then Expected('"end"')
1386+ else Expected('a statement');
13481387 end;
13491388 ReleaseTemps(m);
13501389 end;
@@ -1375,7 +1414,7 @@
13751414 directDefer := false;
13761415 while not (tok in [sEnd, sElse, sElsif, sUntil, sBar, sEof]) do begin
13771416 Statement;
1378- if not skipped or (tok = sSemicolon) then Expect(sSemicolon, ';');
1417+ if not skipped or (tok = sSemicolon) then Expect(sSemicolon);
13791418 end;
13801419 RunDefers(base);
13811420 numDefers := base;
@@ -1399,7 +1438,7 @@
13991438 dec(d);
14001439 if (d = 0) and sawBegin then begin Next; exit end;
14011440 end;
1402- sEof: Mark('end expected');
1441+ sEof: Expected('"end"');
14031442 end;
14041443 Next;
14051444 until false;
@@ -1430,13 +1469,13 @@
14301469 o := q;
14311470 end;
14321471 Declarations(false);
1433- Expect(sBegin, 'begin');
1472+ Expect(sBegin);
14341473 old := curResult;
14351474 curResult := sig^.base;
14361475 EnterBody(p^.chunk, line);
14371476 Statements;
14381477 NoteLine(CurLine);
1439- Expect(sEnd, 'end');
1478+ Expect(sEnd);
14401479 EndProc(p^.chunk);
14411480 curResult := old;
14421481 CloseScope;
@@ -1466,7 +1505,7 @@
14661505 repeat
14671506 start := TokPos;
14681507 v := ConstExpr;
1469- if (v < 0) or (v > 255) then MarkAt(SpanFrom(start), 'a byte expected');
1508+ if (v < 0) or (v > 255) then MarkAt(SpanFrom(start), 'expected a byte from 0 to 255, found ' + IntStr(v));
14701509 Put1(v);
14711510 if tok <> sComma then break;
14721511 Next;
@@ -1483,11 +1522,11 @@
14831522 IdentDef(n, exp);
14841523 at := SpanFrom(at);
14851524 sig := Signature;
1486- Expect(sSemicolon, ';');
1525+ Expect(sSemicolon);
14871526 p := Find(TopScope, n);
14881527 if (p <> nil) and (p^.cls = oProc) and p^.fwd then begin
1489- if not Same(p^.typ, sig) then MarkAt(at, 'not the signature it was declared with');
1490- if tok = sForward then Mark('declared forward twice');
1528+ if not Same(p^.typ, sig) then MarkAt(at, NameOf(n) + ' doesn''t have the signature it was declared forward with');
1529+ if tok = sForward then Mark(NameOf(n) + ' is declared forward twice');
14911530 p^.exported := p^.exported or exp;
14921531 end else begin
14931532 p := NewObj(oProc, n, sig);
@@ -1511,7 +1550,7 @@
15111550 end;
15121551 if checkMode then SkipBody else Body(p, sig, line);
15131552 if tok = sIdent then begin
1514- if id <> n then Mark('the procedure is ' + NameOf(n));
1553+ if id <> n then Mark('expected ' + NameOf(n) + ', found ' + NameOf(id));
15151554 Next;
15161555 end;
15171556 end;
@@ -1541,11 +1580,11 @@
15411580 if (t^.base <> nil) and not IsScalar(t^.base) then MarkAt(at, 'C returns a single value');
15421581 o := NewObj(oProc, n, t);
15431582 end else begin
1544- if tok <> sVar then MarkAt(MissingPos, 'proc or var expected');
1583+ if tok <> sVar then Expected('"proc" or "var"');
15451584 Next;
15461585 IdentDef(n, exp);
15471586 WillDeclare(n);
1548- Expect(sColon, ':');
1587+ Expect(sColon);
15491588 declExported := exp;
15501589 t := ParseType;
15511590 declExported := false;
@@ -1569,7 +1608,7 @@
15691608 t := ParseType;
15701609 if t <> tError then MarkAt(SpanFrom(start), 'only an ERROR constant has a type');
15711610 end;
1572- Expect(sEql, '=');
1611+ Expect(sEql);
15731612 Expression(x, nil);
15741613 o := NewObj(oConst, n, x.typ);
15751614 o^.exported := exp and top;
@@ -1579,7 +1618,7 @@
15791618 end else if x.mode = mStr then begin o^.val := x.val; o^.chunk := x.chunk end
15801619 else o^.val := ConstValue(x);
15811620 Declare(o);
1582- Expect(sSemicolon, ';');
1621+ Expect(sSemicolon);
15831622 end;
15841623
15851624 procedure TypeDecl(top: boolean);
@@ -1587,7 +1626,7 @@
15871626 begin
15881627 IdentDef(n, exp);
15891628 WillDeclare(n);
1590- Expect(sEql, '=');
1629+ Expect(sEql);
15911630 declExported := exp and top;
15921631 inTypes := true;
15931632 t := ParseType;
@@ -1595,7 +1634,7 @@
15951634 o^.exported := exp and top;
15961635 if t^.obj = nil then t^.obj := o;
15971636 Declare(o);
1598- Expect(sSemicolon, ';');
1637+ Expect(sSemicolon);
15991638 end;
16001639
16011640 procedure VarDecl(top: boolean);
@@ -1605,14 +1644,14 @@
16051644 begin
16061645 k := 0;
16071646 repeat
1608- if k > High(names) then Mark('too many names');
1647+ if k > High(names) then Mark('more than ' + IntStr(High(names) + 1) + ' names in one declaration');
16091648 IdentDef(names[k], exps[k]);
16101649 WillDeclare(names[k]);
16111650 inc(k);
16121651 if tok <> sComma then break;
16131652 Next;
16141653 until false;
1615- Expect(sColon, ':');
1654+ Expect(sColon);
16161655 declExported := top and exps[0];
16171656 t := ParseType;
16181657 declExported := false;
@@ -1630,7 +1669,7 @@
16301669 end;
16311670 Declare(o);
16321671 end;
1633- Expect(sSemicolon, ';');
1672+ Expect(sSemicolon);
16341673 end;
16351674
16361675 { After a procedure had an error: its name is poison if it wasn't
@@ -1669,12 +1708,12 @@
16691708 sProc: begin
16701709 if not top then Mark('procedures don''t nest');
16711710 ProcDecl;
1672- Expect(sSemicolon, ';');
1711+ Expect(sSemicolon);
16731712 end;
16741713 sExtern: begin
1675- if not top then Mark('extern only at the top of a module');
1714+ if not top then Mark('extern is only for the top of a module');
16761715 ExternDecl;
1677- Expect(sSemicolon, ';');
1716+ Expect(sSemicolon);
16781717 end;
16791718 end
16801719 else begin
@@ -1736,18 +1775,18 @@
17361775 end;
17371776
17381777 { The arguments of an instance: types, or procedures named. }
1739-procedure ParseArgs(var args: TArgs);
1778+procedure ParseArgs(var args: TArgs; const mname: shortstring);
17401779 var o: PObj; start: TPos;
17411780 begin
17421781 Next;
17431782 repeat
1744- if args.n > High(args.t) then Mark('too many arguments');
1783+ if args.n > High(args.t) then Mark('too many type arguments for ' + mname);
17451784 args.o[args.n] := nil;
17461785 start := TokPos;
17471786 if tok = sIdent then begin
17481787 o := QualIdent;
17491788 if o^.cls = oProc then args.o[args.n] := o
1750- else if o^.cls <> oType then MarkAt(SpanFrom(start), 'a type or a procedure expected');
1789+ else if o^.cls <> oType then MarkAt(SpanFrom(start), NameOf(o^.name) + ' isn''t a type or a procedure');
17511790 args.t[args.n] := o^.typ;
17521791 end else args.t[args.n] := ParseType;
17531792 args.pos[args.n] := SpanFrom(start);
@@ -1755,7 +1794,7 @@
17551794 if tok <> sComma then break;
17561795 Next;
17571796 until false;
1758- Expect(sRparen, ')');
1797+ Expect(sRparen);
17591798 end;
17601799
17611800 { A generic module's parameters, bound to the instance's arguments: a
@@ -1767,8 +1806,9 @@
17671806 s := NameOf(m^.name) + '(';
17681807 Next;
17691808 repeat
1770- if (tok <> sIdent) or (i >= m^.args.n) then MarkAt(m^.args.at, 'needs a type for each type parameter');
1771- if m^.args.o[i] <> nil then MarkAt(m^.args.pos[i], 'needs a type for each type parameter');
1809+ if tok <> sIdent then Expected('a name');
1810+ if i >= m^.args.n then MarkAt(m^.args.at, NameOf(m^.name) + ' needs a type for ' + NameOf(id));
1811+ if m^.args.o[i] <> nil then MarkAt(m^.args.pos[i], NameOf(m^.name) + ' needs a type for ' + NameOf(id));
17721812 Declare(NewObj(oType, id, m^.args.t[i]));
17731813 s := s + TypeName(m^.args.t[i]) + ',';
17741814 inc(i);
@@ -1778,17 +1818,18 @@
17781818 until false;
17791819 while tok = sSemicolon do begin
17801820 Next;
1781- if tok <> sIdent then MarkAt(MissingPos, 'name expected');
1821+ if tok <> sIdent then Expected('a name');
17821822 at := TokPos;
17831823 o := NewObj(oProc, id, nil);
17841824 Next;
1785- Expect(sColon, ':');
1786- Expect(sProc, 'proc');
1825+ Expect(sColon);
1826+ Expect(sProc);
17871827 sig := Signature;
1788- if i >= m^.args.n then MarkAt(m^.args.at, 'needs a procedure for ' + NameOf(o^.name));
1828+ if i >= m^.args.n then MarkAt(m^.args.at, NameOf(m^.name) + ' needs a procedure for ' + NameOf(o^.name));
17891829 a := m^.args.o[i];
1790- if (a = nil) or not Same(a^.typ, sig) then begin
1791- Error(m^.args.pos[i], 'needs a procedure with the signature of ' + NameOf(o^.name));
1830+ if a = nil then MarkAt(m^.args.pos[i], NameOf(m^.name) + ' needs a procedure for ' + NameOf(o^.name));
1831+ if not Same(a^.typ, sig) then begin
1832+ Error(m^.args.pos[i], NameOf(a^.name) + ' doesn''t have the signature of ' + NameOf(o^.name));
17921833 Note(at, NameOf(o^.name) + ' is declared here');
17931834 Finish;
17941835 end;
@@ -1797,8 +1838,8 @@
17971838 s := s + NameOf(a^.module^.name) + '.' + NameOf(a^.name) + ',';
17981839 inc(i);
17991840 end;
1800- Expect(sRparen, ')');
1801- if i <> m^.args.n then MarkAt(m^.args.at, 'too many arguments');
1841+ Expect(sRparen);
1842+ if i <> m^.args.n then MarkAt(m^.args.at, 'too many type arguments for ' + NameOf(m^.name));
18021843 s[length(s)] := ')';
18031844 m^.sname := Name(s);
18041845 end;
@@ -1839,22 +1880,22 @@
18391880 fileChunk := -1;
18401881 checkMode := checkOnly;
18411882 if not checkOnly then begin
1842- if numPending > High(pending) then Mark('modules nested too deeply');
1883+ if numPending > High(pending) then Mark('imports nested more than ' + IntStr(High(pending) + 1) + ' deep');
18431884 pending[numPending] := m;
18441885 inc(numPending);
18451886 end;
18461887 OpenScope(m^.scope);
18471888 Next;
1848- Expect(sModule, 'module');
1849- if (tok <> sIdent) or (id <> n) then Mark('this file must hold module ' + NameOf(n));
1889+ Expect(sModule);
1890+ if (tok <> sIdent) or (id <> n) then Mark('expected module ' + NameOf(n) + ', found ' + Found);
18501891 Next;
18511892 if tok = sLparen then Params(m)
18521893 else if args.n > 0 then MarkAt(args.at, NameOf(n) + ' isn''t generic');
1853- Expect(sSemicolon, ';');
1894+ Expect(sSemicolon);
18541895 while tok = sImport do begin
18551896 Next;
18561897 repeat
1857- if tok <> sIdent then MarkAt(MissingPos, 'module name expected');
1898+ if tok <> sIdent then Expected('a module name');
18581899 start := TokPos;
18591900 alias := id;
18601901 mname := id;
@@ -1862,10 +1903,10 @@
18621903 Next;
18631904 if tok = sBecomes then begin
18641905 Next;
1865- if tok <> sIdent then MarkAt(MissingPos, 'module name expected');
1906+ if tok <> sIdent then Expected('a module name');
18661907 mname := id;
18671908 Next;
1868- if tok = sLparen then ParseArgs(iargs);
1909+ if tok = sLparen then ParseArgs(iargs, NameOf(mname));
18691910 end;
18701911 iargs.at := SpanFrom(start);
18711912 im := ImportModule(mname, iargs);
@@ -1879,7 +1920,7 @@
18791920 if tok <> sComma then break;
18801921 Next;
18811922 until false;
1882- Expect(sSemicolon, ';');
1923+ Expect(sSemicolon);
18831924 end;
18841925 while tok = sLink do begin
18851926 Next;
@@ -1890,9 +1931,9 @@
18901931 lib^.next := m^.libs;
18911932 m^.libs := lib;
18921933 m^.usesC := true;
1893- end else Mark('a library or static expected');
1934+ end else Expected('a library or "static"');
18941935 Next;
1895- Expect(sSemicolon, ';');
1936+ Expect(sSemicolon);
18961937 end;
18971938 Declarations(true);
18981939 if tok = sBegin then begin
@@ -1908,13 +1949,13 @@
19081949 EnterBody(body, line);
19091950 Statements;
19101951 NoteLine(CurLine);
1911- Expect(sEnd, 'end');
1952+ Expect(sEnd);
19121953 EndProc(body);
19131954 end;
1914- end else Expect(sEnd, 'end');
1915- if (tok <> sIdent) or (id <> n) then Mark('end ' + NameOf(n) + ' expected');
1955+ end else Expect(sEnd);
1956+ if (tok <> sIdent) or (id <> n) then Expected(NameOf(n));
19161957 Next;
1917- if tok <> sPeriod then MarkAt(MissingPos, '. expected');
1958+ if tok <> sPeriod then Expected('"."');
19181959 o := m^.first;
19191960 while o <> nil do begin
19201961 if (o^.cls = oProc) and o^.fwd then Error(TokPos, NameOf(o^.name) + ' is declared forward but never defined');

src/raz.pas modified +2 -2

@@ -66,7 +66,7 @@
6666 seen := false;
6767 for i := 0 to numNeeded - 1 do seen := seen or (needed[i] = l^.name);
6868 if not seen then begin
69- if numNeeded > High(needed) then Fatal('too many libraries');
69+ if numNeeded > High(needed) then Fatal('more than ' + IntStr(High(needed) + 1) + ' libraries');
7070 needed[numNeeded] := l^.name;
7171 inc(numNeeded);
7272 end;
@@ -107,7 +107,7 @@
107107 s := ParamStr(i);
108108 if s = '-I' then begin
109109 inc(i);
110- if numInc > High(incDirs) then Fatal('too many -I');
110+ if numInc > High(incDirs) then Fatal('more than ' + IntStr(High(incDirs) + 1) + ' -I directories');
111111 incDirs[numInc] := ParamStr(i);
112112 inc(numInc);
113113 end else if s = '-o' then begin

src/scan.pas modified +70 -22

@@ -70,7 +70,10 @@
7070 procedure Next;
7171 procedure Mark(const msg: shortstring);
7272 procedure MarkAt(const p: TPos; const msg: shortstring);
73+procedure MarkHelp(const p: TPos; const msg, hint: shortstring);
7374 function AtLineStart: boolean;
75+function SymText(s: TSym): shortstring;
76+function Found: shortstring;
7477
7578 var
7679 { Where the parser goes on after an error: the innermost statement or
@@ -100,6 +103,10 @@
100103 'in', 'link', 'match', 'mod', 'module', 'not', 'of', 'or', 'packed',
101104 'proc', 'record', 'repeat', 'return', 'set', 'shl', 'shr', 'then',
102105 'to', 'type', 'until', 'var', 'variant', 'VOLATILE', 'while', 'xor');
106+ Ops: array[sPlus..sBar] of string[3] = (
107+ '+', '-', '*', '/', '=', '#', '<', '<=', '>', '>=',
108+ ':=', ':', ';', ',', '.', '..', '...',
109+ '(', ')', '[', ']', '{', '}', '^', '|');
103110
104111 var
105112 cur: TScanState; { buf .. path; tok, ival, rval and id live above }
@@ -239,6 +246,14 @@
239246 longjmp(recovery^, 1);
240247 end;
241248
249+{ MarkAt, with a line of help after the message. }
250+procedure MarkHelp(const p: TPos; const msg, hint: shortstring);
251+begin
252+ if not quiet then begin Error(p, msg); Help(hint) end;
253+ if recovery = nil then Finish;
254+ longjmp(recovery^, 1);
255+end;
256+
242257 { An error in the text at bytes a to b of the file being read, which
243258 stops the compiler: past it, the symbols can't be trusted. }
244259 procedure MarkBytes(a, b: longint; const msg: shortstring);
@@ -254,6 +269,27 @@
254269 MarkBytes(cur.tokPos, cur.pos, msg);
255270 end;
256271
272+{ How an operator or reserved word is written, quoted, for messages. }
273+function SymText(s: TSym): shortstring;
274+begin
275+ if s in [sPlus..sBar] then SymText := '"' + Ops[s] + '"'
276+ else SymText := '"' + Words[ord(s) - ord(sAnd)] + '"';
277+end;
278+
279+{ The current symbol, for "expected ..., found ...": a name as it is,
280+ a literal by its kind, an operator or reserved word quoted. }
281+function Found: shortstring;
282+begin
283+ case tok of
284+ sIdent: Found := NameOf(id);
285+ sInt, sReal: Found := 'a number';
286+ sChar: Found := 'a character';
287+ sString: Found := 'a string';
288+ sEof: Found := 'the end of the file';
289+ else Found := SymText(tok);
290+ end;
291+end;
292+
257293 { The current symbol is the first on its line: at the top level of a
258294 module, by the usual layout, so where reading can start again. }
259295 function AtLineStart: boolean;
@@ -324,7 +360,7 @@
324360 $F4: begin n := 3; cp := 4; hi := $8F end; { up to 10FFFFH }
325361 else
326362 cur.tokPos := pos;
327- LexError('bad UTF-8');
363+ LexError('invalid UTF-8');
328364 end;
329365 for i := 1 to n do begin
330366 b1 := byte(cur.buf[pos + i]);
@@ -341,7 +377,7 @@
341377
342378 procedure Put(b: longint);
343379 begin
344- if slen >= MaxStr then LexError('string too long');
380+ if slen >= MaxStr then LexError('a string holds at most ' + IntStr(MaxStr) + ' bytes');
345381 sbuf[slen] := b;
346382 inc(slen);
347383 end;
@@ -369,10 +405,19 @@
369405 end;
370406 end;
371407
408+{ The text of the file from byte a up to but not including b, at most
409+ the 255 bytes a shortstring holds. }
410+function Text(a, b: longint): shortstring;
411+begin
412+ if b - a > 255 then b := a + 255;
413+ SetLength(Text, b - a);
414+ Move(cur.buf[a], Text[1], b - a);
415+end;
416+
372417 { One character of a character or string literal, at buf[pos]: its code
373418 point, or for \xHH, minus one minus the byte. }
374419 function LitChar(inString: boolean): longint;
375-var c: char; v, d, n, esc: longint;
420+var c: char; v, d, n, esc, digits: longint;
376421 begin
377422 c := cur.buf[cur.pos];
378423 esc := cur.pos;
@@ -387,7 +432,7 @@
387432 '0': v := 0;
388433 '\', '''', '"': v := ord(c);
389434 'x': begin
390- if not inString then MarkBytes(esc, cur.pos, '\x only in strings');
435+ if not inString then MarkBytes(esc, cur.pos, '\x is only for strings');
391436 d := HexVal(cur.buf[cur.pos]);
392437 n := HexVal(cur.buf[cur.pos + 1]);
393438 if (d < 0) or (n < 0) then MarkBytes(esc, cur.pos + 2, '\x needs two hex digits');
@@ -395,25 +440,27 @@
395440 v := -1 - (d * 16 + n);
396441 end;
397442 'u': begin
398- if cur.buf[cur.pos] <> '{' then MarkBytes(esc, cur.pos, '\u needs {');
443+ if cur.buf[cur.pos] <> '{' then MarkBytes(esc, cur.pos, 'expected "{" after \u');
399444 inc(cur.pos);
445+ digits := cur.pos;
400446 v := 0; n := 0;
401447 while HexVal(cur.buf[cur.pos]) >= 0 do begin
402448 v := v * 16 + HexVal(cur.buf[cur.pos]);
403449 inc(n); inc(cur.pos);
404- if n > 6 then MarkBytes(esc, cur.pos, 'code point too big');
450+ if n > 6 then MarkBytes(esc, cur.pos, 'a code point has at most 6 hex digits');
405451 end;
406- if (n = 0) or (cur.buf[cur.pos] <> '}') then MarkBytes(esc, cur.pos, 'bad \u{...}');
452+ if (n = 0) or (cur.buf[cur.pos] <> '}') then MarkBytes(esc, cur.pos, 'expected hex digits and "}" after \u{');
407453 inc(cur.pos);
408454 if (v > $10FFFF) or ((v >= $D800) and (v <= $DFFF)) then
409- MarkBytes(esc, cur.pos, 'not a code point');
455+ MarkBytes(esc, cur.pos, Text(digits, cur.pos - 1) + ' isn''t a code point');
410456 end;
411- else MarkBytes(esc, cur.pos, 'unknown escape');
457+ else MarkBytes(esc, cur.pos, 'unknown escape \' + c);
412458 end;
413459 end else if byte(c) >= $80 then
414460 v := Utf8(cur.pos)
415461 else if (c < ' ') or (c = #127) then
416- LexError('unterminated literal')
462+ if inString then LexError('string not closed')
463+ else LexError('character not closed')
417464 else begin
418465 v := ord(c);
419466 inc(cur.pos);
@@ -459,40 +506,41 @@
459506 if cur.buf[cur.pos] = 'H' then begin
460507 v := 0;
461508 for i := start to cur.pos - 1 do begin
462- if v shr 60 <> 0 then LexError('number too big');
509+ if v shr 60 <> 0 then LexError(Text(start, cur.pos) + ' is too big for U64');
463510 v := v * 16 + qword(HexVal(cur.buf[i]));
464511 end;
465512 inc(cur.pos);
466513 tok := sInt;
467514 ival := int64(v); { 16 digits are the bits of a 64-bit word }
468515 end else if (cur.buf[cur.pos] = '.') and (cur.buf[cur.pos + 1] in ['0'..'9']) then begin
469- if not allDec then LexError('bad number');
516+ if not allDec then LexError('a decimal number has only the digits 0 to 9');
470517 inc(cur.pos);
471518 while cur.buf[cur.pos] in ['0'..'9'] do inc(cur.pos);
472519 if cur.buf[cur.pos] = 'E' then begin
473520 inc(cur.pos);
474521 if cur.buf[cur.pos] in ['+', '-'] then inc(cur.pos);
475- if not (cur.buf[cur.pos] in ['0'..'9']) then LexError('bad exponent');
522+ if not (cur.buf[cur.pos] in ['0'..'9']) then LexError('expected a digit in the exponent');
476523 while cur.buf[cur.pos] in ['0'..'9'] do inc(cur.pos);
477524 end;
478- if cur.pos - start > 255 then LexError('number too long');
525+ if cur.pos - start > 255 then LexError('a number has at most 255 characters');
479526 SetLength(s, cur.pos - start);
480527 Move(cur.buf[start], s[1], cur.pos - start);
481528 Val(s, rval, code);
482- if code <> 0 then LexError('bad real');
529+ if code <> 0 then LexError(Text(start, cur.pos) + ' is out of the range of F64');
483530 tok := sReal;
484531 end else begin
485- if not allDec then LexError('hex number needs H');
532+ if not allDec then LexError('a hex number ends with H');
486533 v := 0;
487534 for i := start to cur.pos - 1 do begin
488535 d := ord(cur.buf[i]) - ord('0');
489- if v > (qword(high(int64)) - qword(d)) div 10 then LexError('number too big');
536+ if v > (qword(high(int64)) - qword(d)) div 10 then LexError(Text(start, cur.pos) + ' is too big for I64');
490537 v := v * 10 + qword(d);
491538 end;
492539 tok := sInt;
493540 ival := int64(v);
494541 end;
495- if cur.buf[cur.pos] in ['A'..'Z', 'a'..'z', '_', '0'..'9'] then LexError('bad number');
542+ if cur.buf[cur.pos] in ['A'..'Z', 'a'..'z', '_', '0'..'9'] then
543+ LexError('a name can''t start with a digit');
496544 end;
497545
498546 procedure Next;
@@ -520,7 +568,7 @@
520568 start := cur.pos;
521569 repeat inc(cur.pos)
522570 until not (cur.buf[cur.pos] in ['A'..'Z', 'a'..'z', '0'..'9', '_']);
523- if cur.pos - start > MaxIdent then LexError('name too long');
571+ if cur.pos - start > MaxIdent then LexError('a name has at most ' + IntStr(MaxIdent) + ' characters');
524572 h := Intern(@cur.buf[start], cur.pos - start);
525573 if h < NumWords then tok := TSym(ord(sAnd) + h)
526574 else begin tok := sIdent; id := h end;
@@ -586,13 +634,13 @@
586634 '^': begin inc(cur.pos); tok := sArrow end;
587635 '|': begin inc(cur.pos); tok := sBar end;
588636 #0: begin
589- if cur.pos < cur.len then MarkBytes(cur.pos, cur.pos + 1, 'NUL character');
637+ if cur.pos < cur.len then MarkBytes(cur.pos, cur.pos + 1, 'NUL byte in the text');
590638 tok := sEof;
591639 end;
592640 else
593641 if byte(c) >= $80 then
594- LexError('text outside strings, characters and comments must be ASCII');
595- MarkBytes(cur.pos, cur.pos + 1, 'unexpected character');
642+ LexError('only ASCII outside strings, characters and comments');
643+ MarkBytes(cur.pos, cur.pos + 1, 'unexpected character "' + c + '"');
596644 end;
597645 end;
598646

src/sym.pas modified +1 -1

@@ -199,7 +199,7 @@
199199
200200 procedure OpenScope(s: longint);
201201 begin
202- if depth = MaxDepth then Mark('nested too deeply');
202+ if depth = MaxDepth then Mark('scopes nested more than ' + IntStr(MaxDepth) + ' deep');
203203 scopes[depth] := s;
204204 inc(depth);
205205 end;

src/x64.pas modified +1 -1

@@ -306,7 +306,7 @@
306306
307307 function Mem(base: longint; disp: int64): TMem;
308308 begin
309- if (disp < low(longint)) or (disp > high(longint)) then Mark('offset too big');
309+ if (disp < low(longint)) or (disp > high(longint)) then Mark('an offset beyond 32 bits');
310310 Mem.base := base; Mem.index := NoIndex; Mem.scale := 1;
311311 Mem.disp := disp; Mem.chunk := -1;
312312 end;

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

@@ -1,4 +1,4 @@
1-test/err/AtAnd.raz:5:16: error: and, or need two BOOLs
1+test/err/AtAnd.raz:5:16: error: "and" needs BOOLs, found I64
22 5 | b := b and (x + 1);
33 | ^^^^^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtCall.raz:5:10: error: not a procedure
1+test/err/AtCall.raz:5:10: error: expected a procedure, found I64
22 5 | x := x(1);
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtCondition.raz:5:8: error: a condition is a BOOL
1+test/err/AtCondition.raz:5:8: error: a condition is a BOOL, found I64
22 5 | if x + 1 then end;
33 | ^^^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtConstFit.raz:5:10: error: constant doesn't fit I32
1+test/err/AtConstFit.raz:5:10: error: 3000000005 doesn't fit I32
22 5 | x := 5 + 3000000000;
33 | ^^^^^^^^^^^^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtDeref.raz:5:10: error: not a pointer
1+test/err/AtDeref.raz:5:10: error: expected a pointer, found I64
22 5 | y := x^;
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtIndex.raz:5:12: error: an index is an integer
1+test/err/AtIndex.raz:5:12: error: an index is an integer, found BOOL
22 5 | x := a[b];
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtIndexConst.raz:5:12: error: index out of range
1+test/err/AtIndexConst.raz:5:12: error: index 5 is out of range for a length of 4
22 5 | x := a[2 + 3];
33 | ^^^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtMany.raz:7:16: error: too many arguments
1+test/err/AtMany.raz:7:16: error: too many arguments: Id takes 1
22 7 | x := Id(1, 2 * 3);
33 | ^^^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtMatch.raz:5:11: error: match needs a variant or an enumeration
1+test/err/AtMatch.raz:5:11: error: match needs a variant or an enumeration, found I64
22 5 | match x + 1 do end;
33 | ^^^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtNot.raz:5:14: error: not needs BOOL or an integer
1+test/err/AtNot.raz:5:14: error: "not" needs a BOOL or an integer, found []U8
22 5 | b := not s;
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtNotValue.raz:5:10: error: not a value
1+test/err/AtNotValue.raz:5:10: error: I64 is a type, not a value
22 5 | x := I64 + 1;
33 | ^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPArrayLen.raz:2:9: error: bad array length
1+test/err/AtPArrayLen.raz:2:9: error: an array's length is from 1 to 2^40, found 0
22 2 | var a: [0]I64;
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPByte.raz:3:6: error: a byte expected
1+test/err/AtPByte.raz:3:6: error: expected a byte from 0 to 255, found 300
22 3 | code 300;
33 | ^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPCantAssign.raz:7:8: error: can't assign to this
1+test/err/AtPCantAssign.raz:7:8: error: can't assign to k
22 7 | a, k := two();
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPChar.raz:5:12: error: unexpected character
1+test/err/AtPChar.raz:5:12: error: unexpected character "?"
22 5 | a := 1 ? 2;
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPConstExpr.raz:4:9: error: constant expected
1+test/err/AtPConstExpr.raz:4:9: error: expected a constant
22 4 | var a: [n]I64;
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPElems.raz:5:10: error: wrong number of elements
1+test/err/AtPElems.raz:5:10: error: expected 3 elements, found 2
22 5 | a := [1, 2];
33 | ^^^^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPEscape.raz:5:12: error: unknown escape
1+test/err/AtPEscape.raz:5:12: error: unknown escape \q
22 5 | s := "a\q";
33 | ^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPInc.raz:5:9: error: INC and DEC need an integer variable
1+test/err/AtPInc.raz:5:9: error: INC needs an integer variable
22 5 | INC(a);
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPLen.raz:5:14: error: LEN needs an array or slice
1+test/err/AtPLen.raz:5:14: error: LEN needs an array or a slice, found I64
22 5 | a := LEN(a);
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPNoResult.raz:8:10: error: this procedure returns nothing
1+test/err/AtPNoResult.raz:8:10: error: p returns nothing
22 8 | a := p() + 1;
33 | ^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPNotRecord.raz:5:10: error: not a record
1+test/err/AtPNotRecord.raz:5:10: error: expected a record, found I64
22 5 | a := a.f;
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPNotStmt.raz:5:5: error: not a statement
1+test/err/AtPNotStmt.raz:5:5: error: a isn't a statement
22 5 | a;
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPSetLit.raz:6:14: error: not a name of C
1+test/err/AtPSetLit.raz:6:14: error: an integer constant isn't a name of C
22 6 | s := {r, 1};
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtPtrMinus.raz:5:10: error: different pointer types
1+test/err/AtPtrMinus.raz:5:10: error: different types: ^I64 and ^I32
22 5 | x := p - q;
33 | ^^^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtSliceHi.raz:5:15: error: an index is an integer
1+test/err/AtSliceHi.raz:5:15: error: an index is an integer, found BOOL
22 5 | s := a[0..b];
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/AtSliceLo.raz:5:12: error: an index is an integer
1+test/err/AtSliceLo.raz:5:12: error: an index is an integer, found BOOL
22 5 | s := a[b..2];
33 | ^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/BadProc.raz:2:33: error: needs a procedure with the signature of hash
1+test/err/BadProc.raz:2:33: error: cmp doesn't have the signature of hash
22 2 | import Str, M := Map([]U8, I64, Str.cmp, Str.eq);
33 | ^^^^^^^
44 lib/Map.raz:4:18: note: hash is declared here

test/err/DeclArrayUnknown.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclArrayUnknown.raz:4:8: error: an array literal needs a known array or slice type
2+ 4 | if [1] = [1] then end;
3+ | ^
4+raz: 1 error

test/err/DeclArrayUnknown.raz added +6 -0

@@ -0,0 +1,6 @@
1+module DeclArrayUnknown;
2+proc main*;
3+begin
4+ if [1] = [1] then end;
5+end;
6+end DeclArrayUnknown.

test/err/DeclAtomicPtr.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclAtomicPtr.raz:5:15: error: expected a pointer, found I64
2+ 5 | n := XADD(n, 1);
3+ | ^
4+raz: 1 error

test/err/DeclAtomicPtr.raz added +7 -0

@@ -0,0 +1,7 @@
1+module DeclAtomicPtr;
2+proc main*;
3+var n: I64;
4+begin
5+ n := XADD(n, 1);
6+end;
7+end DeclAtomicPtr.

test/err/DeclAtomicSize.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclAtomicSize.raz:8:15: error: expected an 8-byte integer or a pointer, found U8
2+ 8 | n := XADD(p, 1);
3+ | ^
4+raz: 1 error

test/err/DeclAtomicSize.raz (history) added +10 -0

@@ -0,0 +1,10 @@
1+module DeclAtomicSize;
2+proc main*;
3+var b: U8;
4+var p: ^U8;
5+var n: I64;
6+begin
7+ p := ADR(b);
8+ n := XADD(p, 1);
9+end;
10+end DeclAtomicSize.

test/err/DeclEnumNames.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclEnumNames.raz:2:10: error: an enumeration has at most 256 names
2+ 2 | type E = (
3+ | ^
4+raz: 1 error

test/err/DeclEnumNames.raz added +7 -0

@@ -0,0 +1,7 @@
1+module DeclEnumNames;
2+type E = (
3+ a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121, a122, a123, a124, a125, a126, a127, a128, a129, a130, a131, a132, a133, a134, a135, a136, a137, a138, a139, a140, a141, a142, a143, a144, a145, a146, a147, a148, a149, a150, a151, a152, a153, a154, a155, a156, a157, a158, a159, a160, a161, a162, a163, a164, a165, a166, a167, a168, a169, a170, a171, a172, a173, a174, a175, a176, a177, a178, a179, a180, a181, a182, a183, a184, a185, a186, a187, a188, a189, a190, a191, a192, a193, a194, a195, a196, a197, a198, a199, a200, a201, a202, a203, a204, a205, a206, a207, a208, a209, a210, a211, a212, a213, a214, a215, a216, a217, a218, a219, a220, a221, a222, a223, a224, a225, a226, a227, a228, a229, a230, a231, a232, a233, a234, a235, a236, a237, a238, a239, a240, a241, a242, a243, a244, a245, a246, a247, a248, a249, a250, a251, a252, a253, a254, a255, a256);
4+proc main*;
5+begin
6+end;
7+end DeclEnumNames.

test/err/DeclFieldTwice.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclFieldTwice.raz:6:17: error: field a is given twice
2+ 6 | r := {a: 1, a: 2};
3+ | ^
4+raz: 1 error

test/err/DeclFieldTwice.raz added +8 -0

@@ -0,0 +1,8 @@
1+module DeclFieldTwice;
2+type R = record a: I64; end;
3+proc main*;
4+var r: R;
5+begin
6+ r := {a: 1, a: 2};
7+end;
8+end DeclFieldTwice.

test/err/DeclFwdPtrs.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclFwdPtrs.raz:35:11: error: more than 256 pointers to types not yet declared
2+ 35 | P256 = ^T256;
3+ | ^^^^
4+raz: 1 error

test/err/DeclFwdPtrs.raz (history) added +56 -0

@@ -0,0 +1,56 @@
1+module DeclFwdPtrs;
2+type
3+ P0 = ^T0; P1 = ^T1; P2 = ^T2; P3 = ^T3; P4 = ^T4; P5 = ^T5; P6 = ^T6; P7 = ^T7;
4+ P8 = ^T8; P9 = ^T9; P10 = ^T10; P11 = ^T11; P12 = ^T12; P13 = ^T13; P14 = ^T14; P15 = ^T15;
5+ P16 = ^T16; P17 = ^T17; P18 = ^T18; P19 = ^T19; P20 = ^T20; P21 = ^T21; P22 = ^T22; P23 = ^T23;
6+ P24 = ^T24; P25 = ^T25; P26 = ^T26; P27 = ^T27; P28 = ^T28; P29 = ^T29; P30 = ^T30; P31 = ^T31;
7+ P32 = ^T32; P33 = ^T33; P34 = ^T34; P35 = ^T35; P36 = ^T36; P37 = ^T37; P38 = ^T38; P39 = ^T39;
8+ P40 = ^T40; P41 = ^T41; P42 = ^T42; P43 = ^T43; P44 = ^T44; P45 = ^T45; P46 = ^T46; P47 = ^T47;
9+ P48 = ^T48; P49 = ^T49; P50 = ^T50; P51 = ^T51; P52 = ^T52; P53 = ^T53; P54 = ^T54; P55 = ^T55;
10+ P56 = ^T56; P57 = ^T57; P58 = ^T58; P59 = ^T59; P60 = ^T60; P61 = ^T61; P62 = ^T62; P63 = ^T63;
11+ P64 = ^T64; P65 = ^T65; P66 = ^T66; P67 = ^T67; P68 = ^T68; P69 = ^T69; P70 = ^T70; P71 = ^T71;
12+ P72 = ^T72; P73 = ^T73; P74 = ^T74; P75 = ^T75; P76 = ^T76; P77 = ^T77; P78 = ^T78; P79 = ^T79;
13+ P80 = ^T80; P81 = ^T81; P82 = ^T82; P83 = ^T83; P84 = ^T84; P85 = ^T85; P86 = ^T86; P87 = ^T87;
14+ P88 = ^T88; P89 = ^T89; P90 = ^T90; P91 = ^T91; P92 = ^T92; P93 = ^T93; P94 = ^T94; P95 = ^T95;
15+ P96 = ^T96; P97 = ^T97; P98 = ^T98; P99 = ^T99; P100 = ^T100; P101 = ^T101; P102 = ^T102; P103 = ^T103;
16+ P104 = ^T104; P105 = ^T105; P106 = ^T106; P107 = ^T107; P108 = ^T108; P109 = ^T109; P110 = ^T110; P111 = ^T111;
17+ P112 = ^T112; P113 = ^T113; P114 = ^T114; P115 = ^T115; P116 = ^T116; P117 = ^T117; P118 = ^T118; P119 = ^T119;
18+ P120 = ^T120; P121 = ^T121; P122 = ^T122; P123 = ^T123; P124 = ^T124; P125 = ^T125; P126 = ^T126; P127 = ^T127;
19+ P128 = ^T128; P129 = ^T129; P130 = ^T130; P131 = ^T131; P132 = ^T132; P133 = ^T133; P134 = ^T134; P135 = ^T135;
20+ P136 = ^T136; P137 = ^T137; P138 = ^T138; P139 = ^T139; P140 = ^T140; P141 = ^T141; P142 = ^T142; P143 = ^T143;
21+ P144 = ^T144; P145 = ^T145; P146 = ^T146; P147 = ^T147; P148 = ^T148; P149 = ^T149; P150 = ^T150; P151 = ^T151;
22+ P152 = ^T152; P153 = ^T153; P154 = ^T154; P155 = ^T155; P156 = ^T156; P157 = ^T157; P158 = ^T158; P159 = ^T159;
23+ P160 = ^T160; P161 = ^T161; P162 = ^T162; P163 = ^T163; P164 = ^T164; P165 = ^T165; P166 = ^T166; P167 = ^T167;
24+ P168 = ^T168; P169 = ^T169; P170 = ^T170; P171 = ^T171; P172 = ^T172; P173 = ^T173; P174 = ^T174; P175 = ^T175;
25+ P176 = ^T176; P177 = ^T177; P178 = ^T178; P179 = ^T179; P180 = ^T180; P181 = ^T181; P182 = ^T182; P183 = ^T183;
26+ P184 = ^T184; P185 = ^T185; P186 = ^T186; P187 = ^T187; P188 = ^T188; P189 = ^T189; P190 = ^T190; P191 = ^T191;
27+ P192 = ^T192; P193 = ^T193; P194 = ^T194; P195 = ^T195; P196 = ^T196; P197 = ^T197; P198 = ^T198; P199 = ^T199;
28+ P200 = ^T200; P201 = ^T201; P202 = ^T202; P203 = ^T203; P204 = ^T204; P205 = ^T205; P206 = ^T206; P207 = ^T207;
29+ P208 = ^T208; P209 = ^T209; P210 = ^T210; P211 = ^T211; P212 = ^T212; P213 = ^T213; P214 = ^T214; P215 = ^T215;
30+ P216 = ^T216; P217 = ^T217; P218 = ^T218; P219 = ^T219; P220 = ^T220; P221 = ^T221; P222 = ^T222; P223 = ^T223;
31+ P224 = ^T224; P225 = ^T225; P226 = ^T226; P227 = ^T227; P228 = ^T228; P229 = ^T229; P230 = ^T230; P231 = ^T231;
32+ P232 = ^T232; P233 = ^T233; P234 = ^T234; P235 = ^T235; P236 = ^T236; P237 = ^T237; P238 = ^T238; P239 = ^T239;
33+ P240 = ^T240; P241 = ^T241; P242 = ^T242; P243 = ^T243; P244 = ^T244; P245 = ^T245; P246 = ^T246; P247 = ^T247;
34+ P248 = ^T248; P249 = ^T249; P250 = ^T250; P251 = ^T251; P252 = ^T252; P253 = ^T253; P254 = ^T254; P255 = ^T255;
35+ P256 = ^T256;
36+ T0 = I64; T1 = I64; T2 = I64; T3 = I64; T4 = I64; T5 = I64; T6 = I64; T7 = I64; T8 = I64; T9 = I64; T10 = I64; T11 = I64; T12 = I64; T13 = I64; T14 = I64; T15 = I64;
37+ T16 = I64; T17 = I64; T18 = I64; T19 = I64; T20 = I64; T21 = I64; T22 = I64; T23 = I64; T24 = I64; T25 = I64; T26 = I64; T27 = I64; T28 = I64; T29 = I64; T30 = I64; T31 = I64;
38+ T32 = I64; T33 = I64; T34 = I64; T35 = I64; T36 = I64; T37 = I64; T38 = I64; T39 = I64; T40 = I64; T41 = I64; T42 = I64; T43 = I64; T44 = I64; T45 = I64; T46 = I64; T47 = I64;
39+ T48 = I64; T49 = I64; T50 = I64; T51 = I64; T52 = I64; T53 = I64; T54 = I64; T55 = I64; T56 = I64; T57 = I64; T58 = I64; T59 = I64; T60 = I64; T61 = I64; T62 = I64; T63 = I64;
40+ T64 = I64; T65 = I64; T66 = I64; T67 = I64; T68 = I64; T69 = I64; T70 = I64; T71 = I64; T72 = I64; T73 = I64; T74 = I64; T75 = I64; T76 = I64; T77 = I64; T78 = I64; T79 = I64;
41+ T80 = I64; T81 = I64; T82 = I64; T83 = I64; T84 = I64; T85 = I64; T86 = I64; T87 = I64; T88 = I64; T89 = I64; T90 = I64; T91 = I64; T92 = I64; T93 = I64; T94 = I64; T95 = I64;
42+ T96 = I64; T97 = I64; T98 = I64; T99 = I64; T100 = I64; T101 = I64; T102 = I64; T103 = I64; T104 = I64; T105 = I64; T106 = I64; T107 = I64; T108 = I64; T109 = I64; T110 = I64; T111 = I64;
43+ T112 = I64; T113 = I64; T114 = I64; T115 = I64; T116 = I64; T117 = I64; T118 = I64; T119 = I64; T120 = I64; T121 = I64; T122 = I64; T123 = I64; T124 = I64; T125 = I64; T126 = I64; T127 = I64;
44+ T128 = I64; T129 = I64; T130 = I64; T131 = I64; T132 = I64; T133 = I64; T134 = I64; T135 = I64; T136 = I64; T137 = I64; T138 = I64; T139 = I64; T140 = I64; T141 = I64; T142 = I64; T143 = I64;
45+ T144 = I64; T145 = I64; T146 = I64; T147 = I64; T148 = I64; T149 = I64; T150 = I64; T151 = I64; T152 = I64; T153 = I64; T154 = I64; T155 = I64; T156 = I64; T157 = I64; T158 = I64; T159 = I64;
46+ T160 = I64; T161 = I64; T162 = I64; T163 = I64; T164 = I64; T165 = I64; T166 = I64; T167 = I64; T168 = I64; T169 = I64; T170 = I64; T171 = I64; T172 = I64; T173 = I64; T174 = I64; T175 = I64;
47+ T176 = I64; T177 = I64; T178 = I64; T179 = I64; T180 = I64; T181 = I64; T182 = I64; T183 = I64; T184 = I64; T185 = I64; T186 = I64; T187 = I64; T188 = I64; T189 = I64; T190 = I64; T191 = I64;
48+ T192 = I64; T193 = I64; T194 = I64; T195 = I64; T196 = I64; T197 = I64; T198 = I64; T199 = I64; T200 = I64; T201 = I64; T202 = I64; T203 = I64; T204 = I64; T205 = I64; T206 = I64; T207 = I64;
49+ T208 = I64; T209 = I64; T210 = I64; T211 = I64; T212 = I64; T213 = I64; T214 = I64; T215 = I64; T216 = I64; T217 = I64; T218 = I64; T219 = I64; T220 = I64; T221 = I64; T222 = I64; T223 = I64;
50+ T224 = I64; T225 = I64; T226 = I64; T227 = I64; T228 = I64; T229 = I64; T230 = I64; T231 = I64; T232 = I64; T233 = I64; T234 = I64; T235 = I64; T236 = I64; T237 = I64; T238 = I64; T239 = I64;
51+ T240 = I64; T241 = I64; T242 = I64; T243 = I64; T244 = I64; T245 = I64; T246 = I64; T247 = I64; T248 = I64; T249 = I64; T250 = I64; T251 = I64; T252 = I64; T253 = I64; T254 = I64; T255 = I64;
52+ T256 = I64;
53+proc main*;
54+begin
55+end;
56+end DeclFwdPtrs.

test/err/DeclIntConst.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclIntConst.raz:3:9: error: expected an integer constant, found a real constant
2+ 3 | var a: [1.5]I64;
3+ | ^^^
4+raz: 1 error

test/err/DeclIntConst.raz added +6 -0

@@ -0,0 +1,6 @@
1+module DeclIntConst;
2+proc main*;
3+var a: [1.5]I64;
4+begin
5+end;
6+end DeclIntConst.

test/err/DeclLitNoField.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclLitNoField.raz:6:11: error: R has no field b
2+ 6 | r := {b: 1};
3+ | ^
4+raz: 1 error

test/err/DeclLitNoField.raz added +8 -0

@@ -0,0 +1,8 @@
1+module DeclLitNoField;
2+type R = record a: I64; end;
3+proc main*;
4+var r: R;
5+begin
6+ r := {b: 1};
7+end;
8+end DeclLitNoField.

test/err/DeclLitNotExported.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclLitNotExported.raz:6:11: error: field extra of Plat.Info isn't exported
2+ 6 | i := {extra: 1};
3+ | ^^^^^
4+raz: 1 error

test/err/DeclLitNotExported.raz (history) added +8 -0

@@ -0,0 +1,8 @@
1+module DeclLitNotExported;
2+import Plat;
3+proc main*;
4+var i: Plat.Info;
5+begin
6+ i := {extra: 1};
7+end;
8+end DeclLitNotExported.

test/err/DeclManyElements.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclManyElements.raz:5:2059: error: more than 1024 elements
2+ 5 | a := [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
3+ | ^
4+raz: 1 error

test/err/DeclManyElements.raz (history) added +7 -0

@@ -0,0 +1,7 @@
1+module DeclManyElements;
2+proc main*;
3+var a: []I64;
4+begin
5+ a := [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
6+end;
7+end DeclManyElements.

test/err/DeclManyNames.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclManyNames.raz:2:327: error: more than 64 names in one declaration
2+ 2 | type R = record a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64: I64 end;
3+ | ^^^
4+raz: 1 error

test/err/DeclManyNames.raz (history) added +6 -0

@@ -0,0 +1,6 @@
1+module DeclManyNames;
2+type R = record a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64: I64 end;
3+proc main*;
4+begin
5+end;
6+end DeclManyNames.

test/err/DeclNeedsFields.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclNeedsFields.raz:9:10: error: circle needs its fields
2+ 9 | s := circle;
3+ | ^^^^^^
4+raz: 1 error

test/err/DeclNeedsFields.raz added +11 -0

@@ -0,0 +1,11 @@
1+module DeclNeedsFields;
2+type Shape = variant
3+ circle(r: F64);
4+ dot;
5+end;
6+proc main*;
7+var s: Shape;
8+begin
9+ s := circle;
10+end;
11+end DeclNeedsFields.

test/err/DeclNewAllocator.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclNewAllocator.raz:5:12: error: NEW needs a ^Mem.Allocator, found ^I64
2+ 5 | NEW(p, q);
3+ | ^
4+raz: 1 error

test/err/DeclNewAllocator.raz added +7 -0

@@ -0,0 +1,7 @@
1+module DeclNewAllocator;
2+proc main*;
3+var p, q: ^I64;
4+begin
5+ NEW(p, q);
6+end;
7+end DeclNewAllocator.

test/err/DeclNoField.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclNoField.raz:6:7: error: R has no field b
2+ 6 | r.b := 1;
3+ | ^
4+raz: 1 error

test/err/DeclNoField.raz added +8 -0

@@ -0,0 +1,8 @@
1+module DeclNoField;
2+type R = record a: I64; end;
3+proc main*;
4+var r: R;
5+begin
6+ r.b := 1;
7+end;
8+end DeclNoField.

test/err/DeclNotExported.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclNotExported.raz:6:21: error: hidden isn't exported by DeclHidden
2+ 6 | n := DeclHidden.hidden;
3+ | ^^^^^^
4+raz: 1 error

test/err/DeclNotExported.raz added +8 -0

@@ -0,0 +1,8 @@
1+module DeclNotExported;
2+import DeclHidden;
3+proc main*;
4+var n: I64;
5+begin
6+ n := DeclHidden.hidden;
7+end;
8+end DeclNotExported.

test/err/DeclNotType.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclNotType.raz:4:8: error: n isn't a type
2+ 4 | var a: n;
3+ | ^
4+raz: 1 error

test/err/DeclNotType.raz added +7 -0

@@ -0,0 +1,7 @@
1+module DeclNotType;
2+proc main*;
3+var n: I64;
4+var a: n;
5+begin
6+end;
7+end DeclNotType.

test/err/DeclSetLitType.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclSetLitType.raz:6:10: error: expected a set type, found I64
2+ 6 | n := {r};
3+ | ^
4+raz: 1 error

test/err/DeclSetLitType.raz added +8 -0

@@ -0,0 +1,8 @@
1+module DeclSetLitType;
2+type C = (r, g);
3+proc main*;
4+var n: I64;
5+begin
6+ n := {r};
7+end;
8+end DeclSetLitType.

test/err/DeclSetNames.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclSetNames.raz:6:16: error: a set holds names of an enumeration, found an integer constant
2+ 6 | s := {} + {1};
3+ | ^
4+raz: 1 error

test/err/DeclSetNames.raz added +8 -0

@@ -0,0 +1,8 @@
1+module DeclSetNames;
2+type C = (r, g);
3+proc main*;
4+var s: set of C;
5+begin
6+ s := {} + {1};
7+end;
8+end DeclSetNames.

test/err/DeclSetType.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclSetType.raz:3:15: error: a set needs an enumeration of at most 64 names, found I64
2+ 3 | var s: set of I64;
3+ | ^^^
4+raz: 1 error

test/err/DeclSetType.raz added +6 -0

@@ -0,0 +1,6 @@
1+module DeclSetType;
2+proc main*;
3+var s: set of I64;
4+begin
5+end;
6+end DeclSetType.

test/err/DeclSetUnknown.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclSetUnknown.raz:4:8: error: {} needs a known set type
2+ 4 | if {} = {} then end;
3+ | ^^
4+raz: 1 error

test/err/DeclSetUnknown.raz added +6 -0

@@ -0,0 +1,6 @@
1+module DeclSetUnknown;
2+proc main*;
3+begin
4+ if {} = {} then end;
5+end;
6+end DeclSetUnknown.

test/err/DeclSyscallArg.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/DeclSyscallArg.raz:5:21: error: expected an integer or a pointer, found a real constant
2+ 5 | n := SYSCALL(1, 1.5);
3+ | ^^^
4+raz: 1 error

test/err/DeclSyscallArg.raz (history) added +7 -0

@@ -0,0 +1,7 @@
1+module DeclSyscallArg;
2+proc main*;
3+var n: I64;
4+begin
5+ n := SYSCALL(1, 1.5);
6+end;
7+end DeclSyscallArg.

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

@@ -1,4 +1,4 @@
1-test/err/ErrOrder.raz:5:8: error: procedures and errors compare only with = and #
1+test/err/ErrOrder.raz:5:8: error: "<" doesn't apply to ERROR
22 5 | if A < B then end;
33 | ^^^^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/Field.raz:6:7: error: field extra isn't exported
1+test/err/Field.raz:6:7: error: field extra of Plat.Info isn't exported
22 6 | i.extra := 1;
33 | ^^^^^
44 raz: 1 error

test/err/GenBoolOp.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenBoolOp.raz:6:10: error: "+" doesn't apply to BOOL
2+ 6 | b := b + b;
3+ | ^^^^^
4+raz: 1 error

test/err/GenBoolOp.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenBoolOp;
2+
3+proc main*;
4+var b: BOOL;
5+begin
6+ b := b + b;
7+end;
8+end GenBoolOp.

test/err/GenCodeValue.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenCodeValue.raz:6:10: error: a code procedure with two results can only be called
2+ 6 | f := Two;
3+ | ^^^
4+raz: 1 error

test/err/GenCodeValue.raz (history) added +8 -0

@@ -0,0 +1,8 @@
1+module GenCodeValue;
2+type F = proc(): (I64, I64); proc Two(): (I64, I64); code 0C3H;
3+proc main*;
4+var f: F;
5+begin
6+ f := Two;
7+end;
8+end GenCodeValue.

test/err/GenConvertString.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenConvertString.raz:6:14: error: can't convert a string
2+ 6 | x := I64("a");
3+ | ^^^
4+raz: 1 error

test/err/GenConvertString.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenConvertString;
2+
3+proc main*;
4+var x: I64;
5+begin
6+ x := I64("a");
7+end;
8+end GenConvertString.

test/err/GenConvertType.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenConvertType.raz:6:14: error: I64 is a type, not a value
2+ 6 | x := I64(I64);
3+ | ^^^
4+raz: 1 error

test/err/GenConvertType.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenConvertType;
2+
3+proc main*;
4+var x: I64;
5+begin
6+ x := I64(I64);
7+end;
8+end GenConvertType.

test/err/GenDivOverflow.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenDivOverflow.raz:6:10: error: division overflows
2+ 6 | x := (-9223372036854775807 - 1) div (0 - 1);
3+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+raz: 1 error

test/err/GenDivOverflow.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenDivOverflow;
2+
3+proc main*;
4+var x: I64;
5+begin
6+ x := (-9223372036854775807 - 1) div (0 - 1);
7+end;
8+end GenDivOverflow.

test/err/GenDotsRecord.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenDotsRecord.raz:7:20: error: only a single value goes to ...
2+ 7 | C.printf("%d", r);
3+ | ^
4+raz: 1 error

test/err/GenDotsRecord.raz added +9 -0

@@ -0,0 +1,9 @@
1+module GenDotsRecord;
2+import C;
3+type R = record a, b: I64; end;
4+proc main*;
5+var r: R;
6+begin
7+ C.printf("%d", r);
8+end;
9+end GenDotsRecord.

test/err/GenEnumOp.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenEnumOp.raz:6:10: error: "+" doesn't apply to C
2+ 6 | c := c + c;
3+ | ^^^^^
4+raz: 1 error

test/err/GenEnumOp.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenEnumOp;
2+type C = (red, green);
3+proc main*;
4+var c: C;
5+begin
6+ c := c + c;
7+end;
8+end GenEnumOp.

test/err/GenErrorString.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenErrorString.raz:2:18: error: an error is made from a string
2+ 2 | const E: ERROR = 1;
3+ | ^
4+raz: 1 error

test/err/GenErrorString.raz added +7 -0

@@ -0,0 +1,7 @@
1+module GenErrorString;
2+const E: ERROR = 1;
3+proc main*;
4+begin
5+
6+end;
7+end GenErrorString.

test/err/GenFrame.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenFrame.raz:7:4: error: frame too big
2+ 7 | end;
3+ | ^
4+raz: 1 error

test/err/GenFrame.raz (history) added +8 -0

@@ -0,0 +1,8 @@
1+module GenFrame;
2+
3+proc main*;
4+var a: [3000000000]U8;
5+begin
6+
7+end;
8+end GenFrame.

test/err/GenIntReal.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenIntReal.raz:6:10: error: can't combine I64 and F64
2+ 6 | y := x + y;
3+ | ^^^^^
4+raz: 1 error

test/err/GenIntReal.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenIntReal;
2+
3+proc main*;
4+var x: I64; y: F64;
5+begin
6+ y := x + y;
7+end;
8+end GenIntReal.

test/err/GenIntTypes.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenIntTypes.raz:6:10: error: different types: I32 and I64
2+ 6 | b := a + b;
3+ | ^^^^^
4+raz: 1 error

test/err/GenIntTypes.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenIntTypes;
2+
3+proc main*;
4+var a: I32; b: I64;
5+begin
6+ b := a + b;
7+end;
8+end GenIntTypes.

test/err/GenNotIndexable.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenNotIndexable.raz:6:10: error: expected an array, a slice or a pointer, found I64
2+ 6 | x := x[0];
3+ | ^
4+raz: 1 error

test/err/GenNotIndexable.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenNotIndexable;
2+
3+proc main*;
4+var x: I64;
5+begin
6+ x := x[0];
7+end;
8+end GenNotIndexable.

test/err/GenNotVariable.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenNotVariable.raz:5:7: error: a var parameter needs a variable
2+ 5 | P(1);
3+ | ^
4+raz: 1 error

test/err/GenNotVariable.raz added +7 -0

@@ -0,0 +1,7 @@
1+module GenNotVariable;
2+proc P(var a: I64); begin end;
3+proc main*;
4+begin
5+ P(1);
6+end;
7+end GenNotVariable.

test/err/GenPosition.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenPosition.raz:6:12: error: 5 isn't a position of C
2+ 6 | c := C(5);
3+ | ^
4+raz: 1 error

test/err/GenPosition.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenPosition;
2+type C = (red, green);
3+proc main*;
4+var c: C;
5+begin
6+ c := C(5);
7+end;
8+end GenPosition.

test/err/GenPtrOp.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenPtrOp.raz:6:10: error: "+" doesn't apply to ^I64
2+ 6 | b := p + p;
3+ | ^^^^^
4+raz: 1 error

test/err/GenPtrOp.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenPtrOp;
2+
3+proc main*;
4+var p: ^I64; b: BOOL;
5+begin
6+ b := p + p;
7+end;
8+end GenPtrOp.

test/err/GenRealOp.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenRealOp.raz:6:10: error: "mod" doesn't apply to F64
2+ 6 | x := x mod 2.0;
3+ | ^^^^^^^^^
4+raz: 1 error

test/err/GenRealOp.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenRealOp;
2+
3+proc main*;
4+var x: F64;
5+begin
6+ x := x mod 2.0;
7+end;
8+end GenRealOp.

test/err/GenReturnNone.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenReturnNone.raz:2:28: error: return needs a result of I64
2+ 2 | proc P(): I64; begin return; end;
3+ | ^
4+raz: 1 error

test/err/GenReturnNone.raz added +7 -0

@@ -0,0 +1,7 @@
1+module GenReturnNone;
2+proc P(): I64; begin return; end;
3+proc main*;
4+begin
5+ P();
6+end;
7+end GenReturnNone.

test/err/GenReturnNothing.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenReturnNothing.raz:2:22: error: this procedure returns nothing
2+ 2 | proc P; begin return 1; end;
3+ | ^
4+raz: 1 error

test/err/GenReturnNothing.raz added +7 -0

@@ -0,0 +1,7 @@
1+module GenReturnNothing;
2+proc P; begin return 1; end;
3+proc main*;
4+begin
5+ P();
6+end;
7+end GenReturnNothing.

test/err/GenSetOp.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenSetOp.raz:6:10: error: "<" doesn't apply to CS
2+ 6 | b := a < a;
3+ | ^^^^^
4+raz: 1 error

test/err/GenSetOp.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenSetOp;
2+type C = (red, green); CS = set of C;
3+proc main*;
4+var a: CS; b: BOOL;
5+begin
6+ b := a < a;
7+end;
8+end GenSetOp.

test/err/GenSingleValue.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenSingleValue.raz:6:10: error: expected a single value, found R
2+ 6 | x := r + 1;
3+ | ^
4+raz: 1 error

test/err/GenSingleValue.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenSingleValue;
2+type R = record a, b: I64; end;
3+proc main*;
4+var r: R; x: I64;
5+begin
6+ x := r + 1;
7+end;
8+end GenSingleValue.

test/err/GenSlash.err added +5 -0

@@ -0,0 +1,5 @@
1+test/err/GenSlash.raz:6:10: error: "/" is for reals, found an integer constant
2+ 6 | x := 6 / 3;
3+ | ^^^^^
4+help: integers divide with "div"
5+raz: 1 error

test/err/GenSlash.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenSlash;
2+
3+proc main*;
4+var x: I64;
5+begin
6+ x := 6 / 3;
7+end;
8+end GenSlash.

test/err/GenSlashVar.err added +5 -0

@@ -0,0 +1,5 @@
1+test/err/GenSlashVar.raz:6:10: error: "/" is for reals, found I64
2+ 6 | x := x / y;
3+ | ^^^^^
4+help: integers divide with "div"
5+raz: 1 error

test/err/GenSlashVar.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenSlashVar;
2+
3+proc main*;
4+var x, y: I64;
5+begin
6+ x := x / y;
7+end;
8+end GenSlashVar.

test/err/GenStringAs.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenStringAs.raz:6:10: error: can't use a string as I64
2+ 6 | x := "a";
3+ | ^^^
4+raz: 1 error

test/err/GenStringAs.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenStringAs;
2+
3+proc main*;
4+var x: I64;
5+begin
6+ x := "a";
7+end;
8+end GenStringAs.

test/err/GenStringOperand.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenStringOperand.raz:6:10: error: a string can't be an operand
2+ 6 | x := "a" + 1;
3+ | ^^^
4+raz: 1 error

test/err/GenStringOperand.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenStringOperand;
2+
3+proc main*;
4+var x: I64;
5+begin
6+ x := "a" + 1;
7+end;
8+end GenStringOperand.

test/err/GenTooFew.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenTooFew.raz:6:14: error: too few arguments: Id takes 1
2+ 6 | x := Id();
3+ | ^
4+raz: 1 error

test/err/GenTooFew.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenTooFew;
2+proc Id(a: I64): I64; begin return a; end;
3+proc main*;
4+var x: I64;
5+begin
6+ x := Id();
7+end;
8+end GenTooFew.

test/err/GenTooFewValue.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenTooFewValue.raz:6:8: error: too few arguments
2+ 6 | f();
3+ | ^
4+raz: 1 error

test/err/GenTooFewValue.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenTooFewValue;
2+type F = proc(a: I64);
3+proc main*;
4+var f: F;
5+begin
6+ f();
7+end;
8+end GenTooFewValue.

test/err/GenTooManyValue.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenTooManyValue.raz:6:10: error: too many arguments
2+ 6 | f(1, 2);
3+ | ^
4+raz: 1 error

test/err/GenTooManyValue.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenTooManyValue;
2+type F = proc(a: I64);
3+proc main*;
4+var f: F;
5+begin
6+ f(1, 2);
7+end;
8+end GenTooManyValue.

test/err/GenVarExact.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenVarExact.raz:6:7: error: a var parameter needs exactly I64, found I32
2+ 6 | P(x);
3+ | ^
4+raz: 1 error

test/err/GenVarExact.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenVarExact;
2+proc P(var a: I64); begin end;
3+proc main*;
4+var x: I32;
5+begin
6+ P(x);
7+end;
8+end GenVarExact.

test/err/GenVolCompare.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenVolCompare.raz:6:10: error: can't compare through a volatile pointer
2+ 6 | b := p^ = "a";
3+ | ^^
4+raz: 1 error

test/err/GenVolCompare.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenVolCompare;
2+
3+proc main*;
4+var p: ^VOLATILE [4]U8; b: BOOL;
5+begin
6+ b := p^ = "a";
7+end;
8+end GenVolCompare.

test/err/GenVolCopy.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenVolCopy.raz:6:10: error: can't copy through a volatile pointer
2+ 6 | r := p^;
3+ | ^^
4+raz: 1 error

test/err/GenVolCopy.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenVolCopy;
2+type R = record a, b: I64; end;
3+proc main*;
4+var p: ^VOLATILE R; r: R;
5+begin
6+ r := p^;
7+end;
8+end GenVolCopy.

test/err/GenVolSlice.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenVolSlice.raz:6:10: error: can't make a slice through a volatile pointer
2+ 6 | s := p^;
3+ | ^^
4+raz: 1 error

test/err/GenVolSlice.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenVolSlice;
2+
3+proc main*;
4+var p: ^VOLATILE [4]I64; s: []I64;
5+begin
6+ s := p^;
7+end;
8+end GenVolSlice.

test/err/GenVolVar.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/GenVolVar.raz:6:7: error: can't pass through a volatile pointer to a var parameter
2+ 6 | P(p^);
3+ | ^^
4+raz: 1 error

test/err/GenVolVar.raz added +8 -0

@@ -0,0 +1,8 @@
1+module GenVolVar;
2+proc P(var a: I64); begin end;
3+proc main*;
4+var p: ^VOLATILE I64;
5+begin
6+ P(p^);
7+end;
8+end GenVolVar.

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

@@ -1,4 +1,4 @@
1-test/err/NegU64.raz:5:10: error: constant doesn't fit U64
1+test/err/NegU64.raz:5:10: error: -1 doesn't fit U64
22 5 | u := -1;
33 | ^^
44 raz: 1 error

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

@@ -1,4 +1,4 @@
1-test/err/NoArgs.raz:2:8: error: needs a type for each type parameter
1+test/err/NoArgs.raz:2:8: error: List needs a type for T
22 2 | import List;
33 | ^^^^
44 raz: 1 error

test/err/Recover.err modified +2 -2

@@ -19,10 +19,10 @@
1919 test/err/Recover.raz:22:12: error: can't combine I64 and BOOL
2020 22 | return x + true;
2121 | ^^^^^^^^
22-test/err/Recover.raz:28:7: error: no field c
22+test/err/Recover.raz:28:7: error: Q has no field c
2323 28 | q.c := 1;
2424 | ^
25-test/err/Recover.raz:30:18: error: ; expected
25+test/err/Recover.raz:30:18: error: expected ";", found "return"
2626 30 | Out.str("hi")
2727 | ^
2828 test/err/Recover.raz:37:13: error: nope isn't declared

test/err/Resync.err modified +6 -6

@@ -1,19 +1,19 @@
1-test/err/Resync.raz:10:5: error: ; expected
1+test/err/Resync.raz:10:5: error: expected ";", found a
22 10 | end a;
33 | ^
4-test/err/Resync.raz:14:31: error: ; expected
4+test/err/Resync.raz:14:31: error: expected ";", found "end"
55 14 | while x > 0 do x := x - 1 end;
66 | ^^^
7-test/err/Resync.raz:15:10: error: expression expected
7+test/err/Resync.raz:15:10: error: expected an expression, found ")"
88 15 | x := ) + 2;
99 | ^
10-test/err/Resync.raz:16:11: error: match needs a variant or an enumeration
10+test/err/Resync.raz:16:11: error: match needs a variant or an enumeration, found I64
1111 16 | match x
1212 | ^
13-test/err/Resync.raz:23:13: error: expression expected
13+test/err/Resync.raz:23:13: error: expected an expression, found ";"
1414 23 | x := 1 +;
1515 | ^
16-test/err/Resync.raz:23:14: error: end expected
16+test/err/Resync.raz:23:14: error: expected "end", found "proc"
1717 23 | x := 1 +;
1818 | ^
1919 test/err/Resync.raz:27:10: error: can't use BOOL as I64

test/err/ScanBigDec.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanBigDec.raz:5:10: error: 9223372036854775808 is too big for I64
2+ 5 | x := 9223372036854775808;
3+ | ^^^^^^^^^^^^^^^^^^^
4+raz: 1 error

test/err/ScanBigDec.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanBigDec;
2+proc main*;
3+var x: I64;
4+begin
5+ x := 9223372036854775808;
6+end;
7+end ScanBigDec.

test/err/ScanBigHex.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanBigHex.raz:5:10: error: 10000000000000000 is too big for U64
2+ 5 | x := 10000000000000000H;
3+ | ^^^^^^^^^^^^^^^^^
4+raz: 1 error

test/err/ScanBigHex.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanBigHex;
2+proc main*;
3+var x: U64;
4+begin
5+ x := 10000000000000000H;
6+end;
7+end ScanBigHex.

test/err/ScanCharEmpty.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanCharEmpty.raz:5:10: error: empty character
2+ 5 | c := '';
3+ | ^
4+raz: 1 error

test/err/ScanCharEmpty.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanCharEmpty;
2+proc main*;
3+var c: U8;
4+begin
5+ c := '';
6+end;
7+end ScanCharEmpty.

test/err/ScanCharOpen.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanCharOpen.raz:5:10: error: character not closed
2+ 5 | c := 'ab';
3+ | ^^
4+raz: 1 error

test/err/ScanCharOpen.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanCharOpen;
2+proc main*;
3+var c: U8;
4+begin
5+ c := 'ab';
6+end;
7+end ScanCharOpen.

test/err/ScanCodePoint.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanCodePoint.raz:5:11: error: 110000 isn't a code point
2+ 5 | s := "\u{110000}";
3+ | ^^^^^^^^^^
4+raz: 1 error

test/err/ScanCodePoint.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanCodePoint;
2+proc main*;
3+var s: [4]U8;
4+begin
5+ s := "\u{110000}";
6+end;
7+end ScanCodePoint.

test/err/ScanComment.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanComment.raz:4:5: error: comment not closed
2+ 4 | (* never closed
3+ | ^^
4+raz: 1 error

test/err/ScanComment.raz added +6 -0

@@ -0,0 +1,6 @@
1+module ScanComment;
2+proc main*;
3+begin
4+ (* never closed
5+end;
6+end ScanComment.

test/err/ScanExponent.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanExponent.raz:5:10: error: expected a digit in the exponent
2+ 5 | x := 1.5E+;
3+ | ^^^^^
4+raz: 1 error

test/err/ScanExponent.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanExponent;
2+proc main*;
3+var x: F64;
4+begin
5+ x := 1.5E+;
6+end;
7+end ScanExponent.

test/err/ScanHexChar.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanHexChar.raz:5:11: error: \x is only for strings
2+ 5 | c := '\x41';
3+ | ^^
4+raz: 1 error

test/err/ScanHexChar.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanHexChar;
2+proc main*;
3+var c: U8;
4+begin
5+ c := '\x41';
6+end;
7+end ScanHexChar.

test/err/ScanHexDigits.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanHexDigits.raz:5:11: error: \x needs two hex digits
2+ 5 | s := "\xZ1";
3+ | ^^^^
4+raz: 1 error

test/err/ScanHexDigits.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanHexDigits;
2+proc main*;
3+var s: [4]U8;
4+begin
5+ s := "\xZ1";
6+end;
7+end ScanHexDigits.

test/err/ScanHexH.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanHexH.raz:5:10: error: a hex number ends with H
2+ 5 | x := 12A;
3+ | ^^^
4+raz: 1 error

test/err/ScanHexH.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanHexH;
2+proc main*;
3+var x: I64;
4+begin
5+ x := 12A;
6+end;
7+end ScanHexH.

test/err/ScanMain.err added +1 -0

@@ -0,0 +1 @@
1+raz: main must be proc main* or proc main*: I64

test/err/ScanMain.raz added +5 -0

@@ -0,0 +1,5 @@
1+module ScanMain;
2+proc main*(n: I64);
3+begin
4+end;
5+end ScanMain.

test/err/ScanName.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanName.raz:4:5: error: a name has at most 63 characters
2+ 4 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
3+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+raz: 1 error

test/err/ScanName.raz added +6 -0

@@ -0,0 +1,6 @@
1+module ScanName;
2+proc main*;
3+begin
4+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
5+end;
6+end ScanName.

test/err/ScanNameDigit.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanNameDigit.raz:5:10: error: a name can't start with a digit
2+ 5 | x := 12abc;
3+ | ^^
4+raz: 1 error

test/err/ScanNameDigit.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanNameDigit;
2+proc main*;
3+var x: I64;
4+begin
5+ x := 12abc;
6+end;
7+end ScanNameDigit.

test/err/ScanNul.err added

Binary file; the patch has it.

test/err/ScanNul.raz added

Binary file; the patch has it.

test/err/ScanRealHex.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanRealHex.raz:5:10: error: a decimal number has only the digits 0 to 9
2+ 5 | x := 1A.5;
3+ | ^^
4+raz: 1 error

test/err/ScanRealHex.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanRealHex;
2+proc main*;
3+var x: F64;
4+begin
5+ x := 1A.5;
6+end;
7+end ScanRealHex.

test/err/ScanStringOpen.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanStringOpen.raz:5:10: error: string not closed
2+ 5 | s := "abc;
3+ | ^^^^^
4+raz: 1 error

test/err/ScanStringOpen.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanStringOpen;
2+proc main*;
3+var s: [4]U8;
4+begin
5+ s := "abc;
6+end;
7+end ScanStringOpen.

test/err/ScanTwice.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanTwice.raz:4:11: error: x is declared twice
2+ 4 | x: I64;
3+ | ^
4+raz: 1 error

test/err/ScanTwice.raz added +8 -0

@@ -0,0 +1,8 @@
1+module ScanTwice;
2+proc main*;
3+var x: I64;
4+ x: I64;
5+begin
6+
7+end;
8+end ScanTwice.

test/err/ScanUBad.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanUBad.raz:5:11: error: expected hex digits and "}" after \u{
2+ 5 | s := "\u{41";
3+ | ^^^^^
4+raz: 1 error

test/err/ScanUBad.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanUBad;
2+proc main*;
3+var s: [4]U8;
4+begin
5+ s := "\u{41";
6+end;
7+end ScanUBad.

test/err/ScanUBig.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanUBig.raz:5:11: error: a code point has at most 6 hex digits
2+ 5 | s := "\u{1234567}";
3+ | ^^^^^^^^^^
4+raz: 1 error

test/err/ScanUBig.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanUBig;
2+proc main*;
3+var s: [4]U8;
4+begin
5+ s := "\u{1234567}";
6+end;
7+end ScanUBig.

test/err/ScanUBrace.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanUBrace.raz:5:11: error: expected "{" after \u
2+ 5 | s := "\u0041";
3+ | ^^
4+raz: 1 error

test/err/ScanUBrace.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanUBrace;
2+proc main*;
3+var s: [4]U8;
4+begin
5+ s := "\u0041";
6+end;
7+end ScanUBrace.

test/err/ScanUtf8.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/ScanUtf8.raz:5:11: error: invalid UTF-8
2+ 5 | s := "ÿ";
3+ | ^
4+raz: 1 error

test/err/ScanUtf8.raz added +7 -0

@@ -0,0 +1,7 @@
1+module ScanUtf8;
2+proc main*;
3+var s: [4]U8;
4+begin
5+ s := "ÿ";
6+end;
7+end ScanUtf8.

test/err/StmtArgKind.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtArgKind.raz:2:23: error: Page isn't a type or a procedure
2+ 2 | import Mem, L := List(Mem.Page);
3+ | ^^^^^^^^
4+raz: 1 error

test/err/StmtArgKind.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtArgKind;
2+import Mem, L := List(Mem.Page);
3+end StmtArgKind.

test/err/StmtAssignConst.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtAssignConst.raz:5:5: error: can't assign to k
2+ 5 | k := 2;
3+ | ^
4+raz: 1 error

test/err/StmtAssignConst.raz added +7 -0

@@ -0,0 +1,7 @@
1+module StmtAssignConst;
2+const k = 1;
3+proc main*;
4+begin
5+ k := 2;
6+end;
7+end StmtAssignConst.

test/err/StmtAssignValue.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtAssignValue.raz:7:8: error: can't assign to a value
2+ 7 | r, f().a := f(), f().a;
3+ | ^^^^^
4+raz: 1 error

test/err/StmtAssignValue.raz added +9 -0

@@ -0,0 +1,9 @@
1+module StmtAssignValue;
2+type R = record a: I64; end;
3+proc f(): R; var r: R; begin return r; end;
4+proc main*;
5+var r: R;
6+begin
7+ r, f().a := f(), f().a;
8+end;
9+end StmtAssignValue.

test/err/StmtCReturns.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtCReturns.raz:3:13: error: C returns a single value
2+ 3 | extern proc f(): R;
3+ | ^
4+raz: 1 error

test/err/StmtCReturns.raz (history) added +4 -0

@@ -0,0 +1,4 @@
1+module StmtCReturns;
2+type R = record a: I64; end;
3+extern proc f(): R;
4+end StmtCReturns.

test/err/StmtCaseName.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtCaseName.raz:11:7: error: expected a case, found a number
2+ 11 | | 5:
3+ | ^
4+raz: 1 error

test/err/StmtCaseName.raz added +14 -0

@@ -0,0 +1,14 @@
1+module StmtCaseName;
2+type S = variant
3+ circle(r: F64);
4+ rect(w, h: F64);
5+ dot;
6+end;
7+proc main*;
8+var s: S;
9+begin
10+ match s of
11+ | 5:
12+ end;
13+end;
14+end StmtCaseName.

test/err/StmtCaseTwice.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtCaseTwice.raz:12:7: error: dot has two arms
2+ 12 | | dot:
3+ | ^^^
4+raz: 1 error

test/err/StmtCaseTwice.raz added +16 -0

@@ -0,0 +1,16 @@
1+module StmtCaseTwice;
2+type S = variant
3+ circle(r: F64);
4+ rect(w, h: F64);
5+ dot;
6+end;
7+proc main*;
8+var s: S;
9+begin
10+ match s of
11+ | dot:
12+ | dot:
13+ | else:
14+ end;
15+end;
16+end StmtCaseTwice.

test/err/StmtCodeParams.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtCodeParams.raz:2:6: error: too many parameters for a code procedure
2+ 2 | proc f(a, b, c, d, e, f, g: I64);
3+ | ^
4+raz: 1 error

test/err/StmtCodeParams.raz (history) added +4 -0

@@ -0,0 +1,4 @@
1+module StmtCodeParams;
2+proc f(a, b, c, d, e, f, g: I64);
3+code 0C3H;
4+end StmtCodeParams.

test/err/StmtCodeResult.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtCodeResult.raz:3:6: error: a code procedure returns a single value
2+ 3 | proc f: R;
3+ | ^
4+raz: 1 error

test/err/StmtCodeResult.raz (history) added +5 -0

@@ -0,0 +1,5 @@
1+module StmtCodeResult;
2+type R = record a: I64; end;
3+proc f: R;
4+code 0C3H;
5+end StmtCodeResult.

test/err/StmtCodeTakes.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtCodeTakes.raz:3:6: error: a code procedure takes integers, BOOL, reals, pointers and procedures
2+ 3 | proc f(r: R);
3+ | ^
4+raz: 1 error

test/err/StmtCodeTakes.raz (history) added +5 -0

@@ -0,0 +1,5 @@
1+module StmtCodeTakes;
2+type R = record a: I64; end;
3+proc f(r: R);
4+code 0C3H;
5+end StmtCodeTakes.

test/err/StmtCodeTwo.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtCodeTwo.raz:2:6: error: a code procedure returns two results only in rax and rdx
2+ 2 | proc f: (F64, I64);
3+ | ^
4+raz: 1 error

test/err/StmtCodeTwo.raz (history) added +4 -0

@@ -0,0 +1,4 @@
1+module StmtCodeTwo;
2+proc f: (F64, I64);
3+code 0C3H;
4+end StmtCodeTwo.

test/err/StmtDot.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtDot.raz:2:12: error: expected ".", found ";"
2+ 2 | end StmtDot;
3+ | ^
4+raz: 1 error

test/err/StmtDot.raz added +2 -0

@@ -0,0 +1,2 @@
1+module StmtDot;
2+end StmtDot;

test/err/StmtElseLast.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtElseLast.raz:12:7: error: else must be the last arm
2+ 12 | | dot:
3+ | ^^^
4+raz: 1 error

test/err/StmtElseLast.raz added +15 -0

@@ -0,0 +1,15 @@
1+module StmtElseLast;
2+type S = variant
3+ circle(r: F64);
4+ rect(w, h: F64);
5+ dot;
6+end;
7+proc main*;
8+var s: S;
9+begin
10+ match s of
11+ | else:
12+ | dot:
13+ end;
14+end;
15+end StmtElseLast.

test/err/StmtEnd.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtEnd.raz:5:12: error: expected "end", found ")"
2+ 5 | a := 1;
3+ | ^
4+raz: 1 error

test/err/StmtEnd.raz added +8 -0

@@ -0,0 +1,8 @@
1+module StmtEnd;
2+proc main*;
3+var a: I64;
4+begin
5+ a := 1;
6+)
7+end;
8+end StmtEnd.

test/err/StmtEndName.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtEndName.raz:2:5: error: expected StmtEndName, found Other
2+ 2 | end Other.
3+ | ^^^^^
4+raz: 1 error

test/err/StmtEndName.raz added +2 -0

@@ -0,0 +1,2 @@
1+module StmtEndName;
2+end Other.

test/err/StmtErrType.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtErrType.raz:2:10: error: only an ERROR constant has a type
2+ 2 | const k: I64 = "a";
3+ | ^^^
4+raz: 1 error

test/err/StmtErrType.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtErrType;
2+const k: I64 = "a";
3+end StmtErrType.

test/err/StmtExternLocal.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtExternLocal.raz:3:3: error: extern is only for the top of a module
2+ 3 | extern proc f;
3+ | ^^^^^^
4+raz: 1 error

test/err/StmtExternLocal.raz (history) added +6 -0

@@ -0,0 +1,6 @@
1+module StmtExternLocal;
2+proc main*;
3+ extern proc f;
4+begin
5+end;
6+end StmtExternLocal.

test/err/StmtFewFields.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtFewFields.raz:11:13: error: name all the fields of rect, or none
2+ 11 | | rect(w):
3+ | ^
4+raz: 1 error

test/err/StmtFewFields.raz added +15 -0

@@ -0,0 +1,15 @@
1+module StmtFewFields;
2+type S = variant
3+ circle(r: F64);
4+ rect(w, h: F64);
5+ dot;
6+end;
7+proc main*;
8+var s: S;
9+begin
10+ match s of
11+ | rect(w):
12+ | else:
13+ end;
14+end;
15+end StmtFewFields.

test/err/StmtFieldName.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtFieldName.raz:11:14: error: expected a name, found a number
2+ 11 | | circle(5):
3+ | ^
4+raz: 1 error

test/err/StmtFieldName.raz added +15 -0

@@ -0,0 +1,15 @@
1+module StmtFieldName;
2+type S = variant
3+ circle(r: F64);
4+ rect(w, h: F64);
5+ dot;
6+end;
7+proc main*;
8+var s: S;
9+begin
10+ match s of
11+ | circle(5):
12+ | else:
13+ end;
14+end;
15+end StmtFieldName.

test/err/StmtForName.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtForName.raz:5:9: error: k isn't a variable
2+ 5 | for k := 1 to 2 do end;
3+ | ^
4+raz: 1 error

test/err/StmtForName.raz added +7 -0

@@ -0,0 +1,7 @@
1+module StmtForName;
2+const k = 1;
3+proc main*;
4+begin
5+ for k := 1 to 2 do end;
6+end;
7+end StmtForName.

test/err/StmtForType.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtForType.raz:5:9: error: a for loop needs an integer or enumeration variable, found BOOL
2+ 5 | for b := 1 to 2 do end;
3+ | ^
4+raz: 1 error

test/err/StmtForType.raz added +7 -0

@@ -0,0 +1,7 @@
1+module StmtForType;
2+proc main*;
3+var b: BOOL;
4+begin
5+ for b := 1 to 2 do end;
6+end;
7+end StmtForType.

test/err/StmtForwardTwice.err added +7 -0

@@ -0,0 +1,7 @@
1+test/err/StmtForwardTwice.raz:3:9: error: f is declared forward twice
2+ 3 | proc f; forward;
3+ | ^^^^^^^
4+test/err/StmtForwardTwice.raz:4:21: error: f is declared forward but never defined
5+ 4 | end StmtForwardTwice.
6+ | ^
7+raz: 2 errors

test/err/StmtForwardTwice.raz added +4 -0

@@ -0,0 +1,4 @@
1+module StmtForwardTwice;
2+proc f; forward;
3+proc f; forward;
4+end StmtForwardTwice.

test/err/StmtFwdPtr.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtFwdPtr.raz:2:11: error: Missing isn't declared
2+ 2 | type P = ^Missing;
3+ | ^^^^^^^
4+raz: 1 error

test/err/StmtFwdPtr.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtFwdPtr;
2+type P = ^Missing;
3+end StmtFwdPtr.

test/err/StmtImportName.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtImportName.raz:2:8: error: expected a module name, found a number
2+ 2 | import 5;
3+ | ^
4+raz: 1 error

test/err/StmtImportName.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtImportName;
2+import 5;
3+end StmtImportName.

test/err/StmtLibrary.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtLibrary.raz:2:6: error: expected a library or "static", found a number
2+ 2 | link 5;
3+ | ^
4+raz: 1 error

test/err/StmtLibrary.raz (history) added +3 -0

@@ -0,0 +1,3 @@
1+module StmtLibrary;
2+link 5;
3+end StmtLibrary.

test/err/StmtManyDefers.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtManyDefers.raz:9:173: error: more than 64 deferred statements in one procedure
2+ 9 | defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1;
3+ | ^^^^^
4+raz: 1 error

test/err/StmtManyDefers.raz (history) added +11 -0

@@ -0,0 +1,11 @@
1+module StmtManyDefers;
2+proc main*;
3+var a: I64;
4+begin
5+ defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1;
6+ defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1;
7+ defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1;
8+ defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1;
9+ defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1; defer a := 1;
10+end;
11+end StmtManyDefers.

test/err/StmtManyFields.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtManyFields.raz:11:17: error: more names than circle has fields
2+ 11 | | circle(r, x):
3+ | ^
4+raz: 1 error

test/err/StmtManyFields.raz added +15 -0

@@ -0,0 +1,15 @@
1+module StmtManyFields;
2+type S = variant
3+ circle(r: F64);
4+ rect(w, h: F64);
5+ dot;
6+end;
7+proc main*;
8+var s: S;
9+begin
10+ match s of
11+ | circle(r, x):
12+ | else:
13+ end;
14+end;
15+end StmtManyFields.

test/err/StmtManyNames.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtManyNames.raz:2:315: error: more than 64 names in one declaration
2+ 2 | var a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64: I64;
3+ | ^^^
4+raz: 1 error

test/err/StmtManyNames.raz (history) added +3 -0

@@ -0,0 +1,3 @@
1+module StmtManyNames;
2+var a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64: I64;
3+end StmtManyNames.

test/err/StmtManyTypeArgs.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtManyTypeArgs.raz:2:8: error: too many type arguments for List
2+ 2 | import L := List(I64, I64);
3+ | ^^^^^^^^^^^^^^^^^^^
4+raz: 1 error

test/err/StmtManyTypeArgs.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtManyTypeArgs;
2+import L := List(I64, I64);
3+end StmtManyTypeArgs.

test/err/StmtManyVars.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtManyVars.raz:5:51: error: more than 16 variables in one assignment
2+ 5 | a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a := 1;
3+ | ^
4+raz: 1 error

test/err/StmtManyVars.raz (history) added +7 -0

@@ -0,0 +1,7 @@
1+module StmtManyVars;
2+proc main*;
3+var a: I64;
4+begin
5+ a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a := 1;
6+end;
7+end StmtManyVars.

test/err/StmtNeedProc.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtNeedProc.raz:2:33: error: Map needs a procedure for hash
2+ 2 | import Str, M := Map([]U8, I64, I64, Str.eq);
3+ | ^^^
4+raz: 1 error

test/err/StmtNeedProc.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtNeedProc;
2+import Str, M := Map([]U8, I64, I64, Str.eq);
3+end StmtNeedProc.

test/err/StmtNeedType.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtNeedType.raz:2:22: error: Map needs a type for K
2+ 2 | import Str, M := Map(Str.cmp, I64, Str.cmp, Str.eq);
3+ | ^^^^^^^
4+raz: 1 error

test/err/StmtNeedType.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtNeedType;
2+import Str, M := Map(Str.cmp, I64, Str.cmp, Str.eq);
3+end StmtNeedType.

test/err/StmtNest.err added +7 -0

@@ -0,0 +1,7 @@
1+test/err/StmtNest.raz:3:3: error: procedures don't nest
2+ 3 | proc inner; forward;
3+ | ^^^^
4+test/err/StmtNest.raz:5:5: error: expected "begin", found "end"
5+ 5 | end;
6+ | ^
7+raz: 2 errors

test/err/StmtNest.raz added +6 -0

@@ -0,0 +1,6 @@
1+module StmtNest;
2+proc main*;
3+ proc inner; forward;
4+begin
5+end;
6+end StmtNest.

test/err/StmtNeverDefined.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtNeverDefined.raz:3:21: error: f is declared forward but never defined
2+ 3 | end StmtNeverDefined.
3+ | ^
4+raz: 1 error

test/err/StmtNeverDefined.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtNeverDefined;
2+proc f; forward;
3+end StmtNeverDefined.

test/err/StmtNoModule.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtNoModule.raz:2:8: error: can't find module Nothing
2+ 2 | import Nothing;
3+ | ^^^^^^^
4+raz: 1 error

test/err/StmtNoModule.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtNoModule;
2+import Nothing;
3+end StmtNoModule.

test/err/StmtNotCase.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtNotCase.raz:11:7: error: square isn't a case of S
2+ 11 | | square: s := dot;
3+ | ^^^^^^
4+raz: 1 error

test/err/StmtNotCase.raz added +15 -0

@@ -0,0 +1,15 @@
1+module StmtNotCase;
2+type S = variant
3+ circle(r: F64);
4+ rect(w, h: F64);
5+ dot;
6+end;
7+proc main*;
8+var s: S;
9+begin
10+ match s of
11+ | square: s := dot;
12+ | else:
13+ end;
14+end;
15+end StmtNotCase.

test/err/StmtNotStmt.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtNotStmt.raz:6:5: error: a value isn't a statement
2+ 6 | r.a;
3+ | ^^^
4+raz: 1 error

test/err/StmtNotStmt.raz added +8 -0

@@ -0,0 +1,8 @@
1+module StmtNotStmt;
2+type R = record a: I64; end;
3+proc main*;
4+var r: R;
5+begin
6+ r.a;
7+end;
8+end StmtNotStmt.

test/err/StmtParamName.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/mods/StmtParam.raz:1:18: error: expected a name, found a number
2+ 1 | module StmtParam(5);
3+ | ^
4+raz: 1 error

test/err/StmtParamName.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtParamName;
2+import L := StmtParam(I64);
3+end StmtParamName.

test/err/StmtProcName.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtProcName.raz:2:23: error: expected main, found mian
2+ 2 | proc main*; begin end mian;
3+ | ^^^^
4+raz: 1 error

test/err/StmtProcName.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtProcName;
2+proc main*; begin end mian;
3+end StmtProcName.

test/err/StmtResults.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtResults.raz:6:16: error: expected a call with 3 results
2+ 6 | a, b, c := two();
3+ | ^^^^^
4+raz: 1 error

test/err/StmtResults.raz added +8 -0

@@ -0,0 +1,8 @@
1+module StmtResults;
2+proc two: (I64, I64); begin return 1, 2; end;
3+proc main*;
4+var a, b, c: I64;
5+begin
6+ a, b, c := two();
7+end;
8+end StmtResults.

test/err/StmtSigForward.err added +7 -0

@@ -0,0 +1,7 @@
1+test/err/StmtSigForward.raz:3:6: error: f doesn't have the signature it was declared forward with
2+ 3 | proc f(a: BOOL); begin end;
3+ | ^
4+test/err/StmtSigForward.raz:4:19: error: f is declared forward but never defined
5+ 4 | end StmtSigForward.
6+ | ^
7+raz: 2 errors

test/err/StmtSigForward.raz added +4 -0

@@ -0,0 +1,4 @@
1+module StmtSigForward;
2+proc f(a: I64); forward;
3+proc f(a: BOOL); begin end;
4+end StmtSigForward.

test/err/StmtStatement.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtStatement.raz:5:13: error: expected a statement, found ")"
2+ 5 | a := 1; )
3+ | ^
4+raz: 1 error

test/err/StmtStatement.raz added +7 -0

@@ -0,0 +1,7 @@
1+module StmtStatement;
2+proc main*;
3+var a: I64;
4+begin
5+ a := 1; )
6+end;
7+end StmtStatement.

test/err/StmtVarOrProc.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/StmtVarOrProc.raz:2:8: error: expected "proc" or "var", found a number
2+ 2 | extern 5;
3+ | ^
4+raz: 1 error

test/err/StmtVarOrProc.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtVarOrProc;
2+extern 5;
3+end StmtVarOrProc.

test/err/StmtWrongModule.err added +4 -0

@@ -0,0 +1,4 @@
1+test/err/mods/StmtOther.raz:1:8: error: expected module StmtOther, found StmtWrong
2+ 1 | module StmtWrong;
3+ | ^^^^^^^^^
4+raz: 1 error

test/err/StmtWrongModule.raz added +3 -0

@@ -0,0 +1,3 @@
1+module StmtWrongModule;
2+import StmtOther;
3+end StmtWrongModule.

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

@@ -1,4 +1,5 @@
1-test/err/Tuple.raz:6:10: error: several results go only to a, b := ...
1+test/err/Tuple.raz:6:10: error: two returns several results
22 6 | a := two() + 1;
33 | ^^^^^
4+help: they go to variables: a, b := two(...)
45 raz: 1 error

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

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

test/err/mods/DeclHidden.raz added +4 -0

@@ -0,0 +1,4 @@
1+module DeclHidden;
2+const shown* = 1;
3+const hidden = 2;
4+end DeclHidden.

test/err/mods/StmtOther.raz added +2 -0

@@ -0,0 +1,2 @@
1+module StmtWrong;
2+end StmtWrong.

test/err/mods/StmtParam.raz added +2 -0

@@ -0,0 +1,2 @@
1+module StmtParam(5);
2+end StmtParam.