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.
| @@ -244,7 +244,7 @@ | ||
| 244 | 244 | and fails on a crash or two messages at one place. Writing it |
| 245 | 245 | and sorting what it finds, *agent*; the fixes in `gen.pas`, |
| 246 | 246 | *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 | |
| 248 | 248 | in `test/err` that pins its position too. *agent*, one per file |
| 249 | 249 | (`scan.pas`, `parse.pas` in two halves, `gen.pas`, the rest), |
| 250 | 250 | against a list of messages and their tests the main model writes |
| @@ -8,12 +8,12 @@ | ||
| 8 | 8 | |
| 9 | 9 | | File | Lines | Code | What | |
| 10 | 10 | |---|---|---|---| |
| 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 | | |
| 13 | 13 | | `src/sym.pas` | 526 | 437 | Types, objects, scopes, layout | |
| 14 | 14 | | `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 | | |
| 17 | 17 | | `src/link.pas` | 131 | 95 | Tree shaking, layout, patching | |
| 18 | 18 | | `src/elf.pas` | 425 | 351 | Static and dynamic ELF, symbol table, line numbers | |
| 19 | 19 | | `src/raz.pas` | 219 | 172 | The command line, the entry points | |
| @@ -143,9 +143,13 @@ | ||
| 143 | 143 | from a saved position to the end of the symbol before the current one, |
| 144 | 144 | and `MissingPos` the place to say a symbol is missing: just after the |
| 145 | 145 | 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 | |
| 149 | 153 | compiler (`MarkBytes`, `LexError`): past a string left open, the |
| 150 | 154 | symbols can't be trusted. There is no |
| 151 | 155 | recovery: the first error ends the compilation. `SaveScan` and `RestoreScan` keep |
| @@ -40,6 +40,7 @@ | ||
| 40 | 40 | procedure Error(const p: TPos; const msg: shortstring); |
| 41 | 41 | procedure Warning(const p: TPos; const msg: shortstring); |
| 42 | 42 | procedure Note(const p: TPos; const msg: shortstring); |
| 43 | +function IntStr(n: int64): shortstring; | |
| 43 | 44 | procedure Help(const msg: shortstring); |
| 44 | 45 | procedure Fatal(const msg: shortstring); |
| 45 | 46 | procedure Finish; |
| @@ -113,7 +114,7 @@ | ||
| 113 | 114 | if colour then Paint := c + s + Plain else Paint := s; |
| 114 | 115 | end; |
| 115 | 116 | |
| 116 | -function IntStr(n: longint): shortstring; | |
| 117 | +function IntStr(n: int64): shortstring; | |
| 117 | 118 | var s: shortstring; |
| 118 | 119 | begin |
| 119 | 120 | Str(n, s); |
| @@ -54,6 +54,7 @@ | ||
| 54 | 54 | n: longint; |
| 55 | 55 | target: int64; { the frame slot of a procedure value, if any } |
| 56 | 56 | chunk: longint; { else the procedure's chunk } |
| 57 | + obj: PObj; { the procedure called, if it has a name } | |
| 57 | 58 | code: boolean; { a code procedure: two results come in rax and rdx } |
| 58 | 59 | ext: boolean; { C's: called through the chunk holding its address } |
| 59 | 60 | isF: array[0..63] of boolean; { each argument: goes in an xmm register } |
| @@ -200,6 +201,20 @@ | ||
| 200 | 201 | SetData(x.chunk, @sbuf, slen + 1, 1); |
| 201 | 202 | end; |
| 202 | 203 | |
| 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 | + | |
| 203 | 218 | procedure MakeItem(var x: TItem; o: PObj); |
| 204 | 219 | begin |
| 205 | 220 | FillChar(x, SizeOf(x), 0); |
| @@ -231,7 +246,7 @@ | ||
| 231 | 246 | oType: x.mode := mType; |
| 232 | 247 | oBuiltin: x.mode := mBuiltin; |
| 233 | 248 | oCase: x.mode := mCase; |
| 234 | - else Mark('not a value'); | |
| 249 | + else Mark(NameOf(o^.name) + ' is not a value'); | |
| 235 | 250 | end; |
| 236 | 251 | end; |
| 237 | 252 | |
| @@ -309,7 +324,7 @@ | ||
| 309 | 324 | |
| 310 | 325 | procedure LoadVar(var x: TItem; r: longint); |
| 311 | 326 | 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)); | |
| 313 | 328 | Load(r, MemOf(x, r), ScalarSize(x.typ), (x.typ^.form = fInt) and x.typ^.signed); |
| 314 | 329 | end; |
| 315 | 330 | |
| @@ -335,7 +350,7 @@ | ||
| 335 | 350 | if x.obj^.ext then Load(RAX, MemRip(x.obj^.chunk, 0), 8, false) |
| 336 | 351 | else Lea(RAX, MemRip(x.obj^.chunk, 0)); |
| 337 | 352 | end; |
| 338 | - else MarkAt(x.pos, 'not a value'); | |
| 353 | + else NotValue(x); | |
| 339 | 354 | end; |
| 340 | 355 | x.mode := mReg; |
| 341 | 356 | end; |
| @@ -348,7 +363,7 @@ | ||
| 348 | 363 | m := MemOf(x, r); |
| 349 | 364 | if (x.base <> bReg) or (x.reg <> r) or (x.off <> 0) then Lea(r, m); |
| 350 | 365 | 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'); | |
| 352 | 367 | end; |
| 353 | 368 | |
| 354 | 369 | procedure Save(var x: TItem); |
| @@ -465,11 +480,11 @@ | ||
| 465 | 480 | end else MarkAt(x.pos, 'can''t use a string as ' + TypeName(t)); |
| 466 | 481 | exit; |
| 467 | 482 | 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); | |
| 469 | 484 | if Same(s, t) then exit; |
| 470 | 485 | if (s = tRConst) and (t^.form = fReal) then RealTo(x, t) |
| 471 | 486 | 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)); | |
| 473 | 488 | x.typ := t; |
| 474 | 489 | end else if (s^.form = fNil) and (t^.form in [fPtr, fProc, fError]) then |
| 475 | 490 | x.typ := t |
| @@ -528,8 +543,8 @@ | ||
| 528 | 543 | var t: PType; |
| 529 | 544 | begin |
| 530 | 545 | 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'); | |
| 533 | 548 | Value(x); |
| 534 | 549 | x.mode := mVar; x.base := bReg; x.reg := RAX; x.off := 0; |
| 535 | 550 | x.typ := t^.base; x.vol := t^.vol; x.isVar := true; |
| @@ -550,7 +565,7 @@ | ||
| 550 | 565 | Value(x); PushRax; x.mode := mStack |
| 551 | 566 | end else if (x.mode = mVar) and (x.typ^.form in [fArray, fSlice]) then |
| 552 | 567 | 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)); | |
| 554 | 569 | end; |
| 555 | 570 | |
| 556 | 571 | procedure Index(var x, y: TItem); |
| @@ -558,7 +573,7 @@ | ||
| 558 | 573 | begin |
| 559 | 574 | t := x.typ; |
| 560 | 575 | 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)); | |
| 562 | 577 | if t^.form = fPtr then begin |
| 563 | 578 | Value(y); |
| 564 | 579 | if s <> 1 then ImulI(RAX, s); |
| @@ -567,7 +582,7 @@ | ||
| 567 | 582 | x.mode := mVar; x.base := bReg; x.reg := RAX; x.off := 0; |
| 568 | 583 | x.vol := t^.vol; x.isVar := true; |
| 569 | 584 | 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)); | |
| 571 | 586 | x.off := x.off + y.val * s; |
| 572 | 587 | if x.base = bStack then begin |
| 573 | 588 | PopR(RAX); x.base := bReg; x.reg := RAX |
| @@ -596,7 +611,7 @@ | ||
| 596 | 611 | |
| 597 | 612 | procedure SliceLo(var lo: TItem); |
| 598 | 613 | 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)); | |
| 600 | 615 | Value(lo); |
| 601 | 616 | PushRax; |
| 602 | 617 | end; |
| @@ -606,7 +621,7 @@ | ||
| 606 | 621 | begin |
| 607 | 622 | t := x.typ; |
| 608 | 623 | 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)); | |
| 610 | 625 | if x.vol then MarkAt(x.pos, 'can''t make a slice through a volatile pointer'); |
| 611 | 626 | Value(hi); |
| 612 | 627 | MovRR(RDX, RAX); |
| @@ -661,7 +676,7 @@ | ||
| 661 | 676 | end else if IsInt(x.typ) then begin |
| 662 | 677 | if x.mode = mConst then x.val := Cut(not x.val, x.typ) |
| 663 | 678 | 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)); | |
| 665 | 680 | end; |
| 666 | 681 | |
| 667 | 682 | function IsStrLike(t: PType): boolean; |
| @@ -699,7 +714,7 @@ | ||
| 699 | 714 | end else if (op in [sEql, sNeq]) and IsStrLike(x.typ) then |
| 700 | 715 | StrSlice(x) |
| 701 | 716 | else if x.mode in [mType, mBuiltin, mNone, mCase, mStr] then |
| 702 | - MarkAt(x.pos, 'not a value') | |
| 717 | + NotValue(x) | |
| 703 | 718 | else if x.mode <> mConst then begin |
| 704 | 719 | Value(x); PushRax; x.mode := mStack |
| 705 | 720 | end; |
| @@ -797,10 +812,10 @@ | ||
| 797 | 812 | xt, yt, t: PType; r: TItem; scale, sh, k: longint; isPtr, unsign, f: boolean; a, b: int64; |
| 798 | 813 | begin |
| 799 | 814 | 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); | |
| 801 | 816 | |
| 802 | 817 | 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)); | |
| 804 | 819 | if (x.mode = mConst) and (y.mode = mConst) then begin |
| 805 | 820 | FixLink(L); |
| 806 | 821 | if op = sAnd then x.val := x.val and y.val else x.val := x.val or y.val; |
| @@ -830,47 +845,47 @@ | ||
| 830 | 845 | { the type of the result, and the checks } |
| 831 | 846 | t := nil; scale := 1; isPtr := false; |
| 832 | 847 | 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"'); | |
| 834 | 849 | if op in [sShl, sShr] then begin |
| 835 | 850 | if xt^.form = fConst then t := tConst else t := xt |
| 836 | 851 | end else if (xt^.form = fConst) and (yt^.form = fConst) then t := tConst |
| 837 | 852 | 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)); | |
| 839 | 854 | t := yt |
| 840 | 855 | 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)); | |
| 842 | 857 | t := xt |
| 843 | 858 | end else if Same(xt, yt) then t := xt |
| 844 | 859 | else MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt)); |
| 845 | 860 | 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)); | |
| 847 | 862 | if xt = tRConst then t := yt |
| 848 | 863 | else if (yt = tRConst) or Same(xt, yt) then t := xt |
| 849 | 864 | else MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt)); |
| 850 | 865 | if (x.mode = mConst) and (x.typ <> t) then RealTo(x, t); |
| 851 | 866 | if (y.mode = mConst) and (y.typ <> t) then RealTo(y, t); |
| 852 | 867 | 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)); | |
| 854 | 869 | t := tBool; |
| 855 | 870 | end else if (xt^.form = fPtr) and IsInt(yt) and (op in [sPlus, sMinus]) then begin |
| 856 | 871 | t := xt; scale := xt^.base^.size; isPtr := true; |
| 857 | 872 | if y.mode = mConst then y.typ := tI64; |
| 858 | 873 | 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)); | |
| 860 | 875 | t := tI64; scale := xt^.base^.size; isPtr := true; |
| 861 | 876 | 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)); | |
| 863 | 878 | 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)); | |
| 865 | 880 | if (xt^.form <> fNil) and (yt^.form <> fNil) and not Same(xt, yt) then |
| 866 | 881 | 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)); | |
| 868 | 883 | t := tU64; |
| 869 | 884 | 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)); | |
| 871 | 886 | t := xt; |
| 872 | 887 | 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)); | |
| 874 | 889 | t := xt; |
| 875 | 890 | end else if (op = sIn) and (yt^.form = fSet) and Same(xt, yt^.base) then |
| 876 | 891 | t := yt |
| @@ -881,7 +896,7 @@ | ||
| 881 | 896 | { constants } |
| 882 | 897 | if (x.mode = mConst) and (y.mode = mConst) and not isPtr then begin |
| 883 | 898 | 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)); | |
| 885 | 900 | x := r; |
| 886 | 901 | end else if t^.form = fSet then begin |
| 887 | 902 | a := x.val; b := y.val; |
| @@ -982,7 +997,7 @@ | ||
| 982 | 997 | sXor: Alu(aluXor, RAX, RCX); |
| 983 | 998 | sShl: Shift(shShl, RAX); |
| 984 | 999 | 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)); | |
| 986 | 1001 | end; |
| 987 | 1002 | Norm(t); |
| 988 | 1003 | end; |
| @@ -994,14 +1009,17 @@ | ||
| 994 | 1009 | var s: PType; r: double; L1, L2: longint; f: boolean; |
| 995 | 1010 | begin |
| 996 | 1011 | 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; | |
| 998 | 1016 | if Same(s, t) then exit; |
| 999 | 1017 | if (IsInt(s) or (s^.form in [fEnum, fSet])) and (t^.form = fInt) then begin |
| 1000 | 1018 | if x.mode = mConst then x.val := Cut(x.val, t) |
| 1001 | 1019 | else begin Value(x); Norm(t) end; |
| 1002 | 1020 | end else if IsInt(s) and (t^.form = fEnum) then begin |
| 1003 | 1021 | 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)) | |
| 1005 | 1023 | end else begin Value(x); CmpI(RAX, t^.len); Check(ccB) end; |
| 1006 | 1024 | end else if IsInt(s) and (t^.form = fSet) then begin |
| 1007 | 1025 | if x.mode = mConst then begin |
| @@ -1066,10 +1084,10 @@ | ||
| 1066 | 1084 | begin |
| 1067 | 1085 | if x.mode = mProc then begin |
| 1068 | 1086 | 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; | |
| 1070 | 1088 | 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)); | |
| 1073 | 1091 | c.sig := x.typ; c.chunk := -1; |
| 1074 | 1092 | c.target := ToSlot(x); |
| 1075 | 1093 | end; |
| @@ -1086,7 +1104,10 @@ | ||
| 1086 | 1104 | { past the parameters of a C procedure that ends in ...: a string |
| 1087 | 1105 | goes as a C string, an integer constant as an I64, a real |
| 1088 | 1106 | 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; | |
| 1090 | 1111 | if a.mode = mStr then Coerce(a, tPtrU8) |
| 1091 | 1112 | else if a.typ^.form = fConst then Coerce(a, tI64) |
| 1092 | 1113 | else if a.typ = tRConst then Coerce(a, tReal) |
| @@ -1100,7 +1121,7 @@ | ||
| 1100 | 1121 | c.isF[c.n] := (p^.typ^.form = fReal) and not p^.isVar; |
| 1101 | 1122 | if p^.isVar then begin |
| 1102 | 1123 | 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)); | |
| 1104 | 1125 | if a.vol then MarkAt(a.pos, 'can''t pass through a volatile pointer to a var parameter'); |
| 1105 | 1126 | Address(a, RAX); |
| 1106 | 1127 | s := AllocTemp(8, 8); |
| @@ -1125,7 +1146,10 @@ | ||
| 1125 | 1146 | res: PType; i, ni, nf, k, pad: longint; ret: int64; |
| 1126 | 1147 | onStack: array[0..63] of boolean; |
| 1127 | 1148 | 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; | |
| 1129 | 1153 | res := c.sig^.base; |
| 1130 | 1154 | ret := 0; |
| 1131 | 1155 | ni := 0; nf := 0; |
| @@ -1169,7 +1193,7 @@ | ||
| 1169 | 1193 | end; |
| 1170 | 1194 | FillChar(x, SizeOf(x), 0); |
| 1171 | 1195 | if res = nil then begin |
| 1172 | - x.mode := mNone; x.typ := tNone | |
| 1196 | + x.mode := mNone; x.typ := tNone; x.obj := c.obj | |
| 1173 | 1197 | end else if ret <> 0 then |
| 1174 | 1198 | TempItem(x, res, ret) |
| 1175 | 1199 | else begin |
| @@ -1220,7 +1244,7 @@ | ||
| 1220 | 1244 | var p: int64; |
| 1221 | 1245 | begin |
| 1222 | 1246 | 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)); | |
| 1224 | 1248 | Address(x, RAX); |
| 1225 | 1249 | p := AllocTemp(8, 8); |
| 1226 | 1250 | Store(Mem(RBP, p), RAX, 8); |
| @@ -1265,7 +1289,7 @@ | ||
| 1265 | 1289 | |
| 1266 | 1290 | procedure CondJump(var x: TItem; var L: longint); |
| 1267 | 1291 | 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)); | |
| 1269 | 1293 | Value(x); |
| 1270 | 1294 | TestRR(RAX, RAX); |
| 1271 | 1295 | Jcc(ccE, L); |
| @@ -1435,7 +1459,7 @@ | ||
| 1435 | 1459 | |
| 1436 | 1460 | procedure ReturnNone; |
| 1437 | 1461 | begin |
| 1438 | - if result <> nil then Mark('return needs a result'); | |
| 1462 | + if result <> nil then Mark('return needs a result of ' + TypeName(result)); | |
| 1439 | 1463 | Jmp(exitL); |
| 1440 | 1464 | end; |
| 1441 | 1465 |
| @@ -54,6 +54,7 @@ | ||
| 54 | 54 | fwdTypes: array[0..255] of PType; |
| 55 | 55 | fwdPos: array[0..255] of TPos; { where each names its type } |
| 56 | 56 | numFwd: longint; |
| 57 | + lastCalled: PObj; { the procedure the last call was of, if it had a name } | |
| 57 | 58 | declExported: boolean; { the export mark of the declaration being read } |
| 58 | 59 | curLoop: PLoop; { the innermost loop, or nil } |
| 59 | 60 | defers: array[0..63] of longint; { the deferred statements in force } |
| @@ -76,9 +77,15 @@ | ||
| 76 | 77 | |
| 77 | 78 | { Little helpers } |
| 78 | 79 | |
| 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); | |
| 80 | 82 | 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)); | |
| 82 | 89 | Next; |
| 83 | 90 | end; |
| 84 | 91 | |
| @@ -89,7 +96,7 @@ | ||
| 89 | 96 | |
| 90 | 97 | procedure IdentDef(var n: longint; var exp: boolean); |
| 91 | 98 | begin |
| 92 | - if tok <> sIdent then MarkAt(MissingPos, 'name expected'); | |
| 99 | + if tok <> sIdent then Expected('a name'); | |
| 93 | 100 | n := id; |
| 94 | 101 | Next; |
| 95 | 102 | exp := false; |
| @@ -228,7 +235,7 @@ | ||
| 228 | 235 | |
| 229 | 236 | function ConstValue(var x: TItem): int64; |
| 230 | 237 | begin |
| 231 | - if x.mode <> mConst then MarkAt(x.pos, 'constant expected'); | |
| 238 | + if x.mode <> mConst then MarkAt(x.pos, 'expected a constant'); | |
| 232 | 239 | ConstValue := x.val; |
| 233 | 240 | end; |
| 234 | 241 | |
| @@ -236,14 +243,14 @@ | ||
| 236 | 243 | var x: TItem; |
| 237 | 244 | begin |
| 238 | 245 | 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)); | |
| 240 | 247 | ConstExpr := ConstValue(x); |
| 241 | 248 | end; |
| 242 | 249 | |
| 243 | 250 | function QualIdent: PObj; |
| 244 | -var o: PObj; | |
| 251 | +var o: PObj; m: PModule; | |
| 245 | 252 | begin |
| 246 | - if tok <> sIdent then MarkAt(MissingPos, 'name expected'); | |
| 253 | + if tok <> sIdent then Expected('a name'); | |
| 247 | 254 | o := Lookup(id); |
| 248 | 255 | if o = nil then begin |
| 249 | 256 | Poison(id); |
| @@ -253,10 +260,11 @@ | ||
| 253 | 260 | if o^.typ = tPoison then quiet := true; |
| 254 | 261 | Next; |
| 255 | 262 | 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)); | |
| 260 | 268 | Next; |
| 261 | 269 | end; |
| 262 | 270 | QualIdent := o; |
| @@ -280,19 +288,19 @@ | ||
| 280 | 288 | begin |
| 281 | 289 | t := NewType(fRecord, 0, 1); |
| 282 | 290 | if tok = sPacked then begin t^.packd := true; Next end; |
| 283 | - Expect(sRecord, 'record'); | |
| 291 | + Expect(sRecord); | |
| 284 | 292 | t^.scope := NewScope; |
| 285 | 293 | off := 0; maxA := 1; last := nil; |
| 286 | 294 | while tok = sIdent do begin |
| 287 | 295 | n := 0; |
| 288 | 296 | 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'); | |
| 290 | 298 | IdentDef(names[n], exps[n]); |
| 291 | 299 | inc(n); |
| 292 | 300 | if tok <> sComma then break; |
| 293 | 301 | Next; |
| 294 | 302 | until false; |
| 295 | - Expect(sColon, ':'); | |
| 303 | + Expect(sColon); | |
| 296 | 304 | ft := ParseType; |
| 297 | 305 | if t^.packd then a := 1 else a := ft^.align; |
| 298 | 306 | for i := 0 to n - 1 do begin |
| @@ -306,9 +314,9 @@ | ||
| 306 | 314 | off := off + ft^.size; |
| 307 | 315 | end; |
| 308 | 316 | if a > maxA then maxA := a; |
| 309 | - Expect(sSemicolon, ';'); | |
| 317 | + Expect(sSemicolon); | |
| 310 | 318 | end; |
| 311 | - Expect(sEnd, 'end'); | |
| 319 | + Expect(sEnd); | |
| 312 | 320 | t^.align := maxA; |
| 313 | 321 | t^.size := AlignUp(off, maxA); |
| 314 | 322 | RecordType := t; |
| @@ -317,7 +325,7 @@ | ||
| 317 | 325 | function VariantType: PType; |
| 318 | 326 | var t, ft: PType; c, lastC, f, lastF: PObj; tag, off, maxSize: int64; n: longint; |
| 319 | 327 | begin |
| 320 | - Expect(sVariant, 'variant'); | |
| 328 | + Expect(sVariant); | |
| 321 | 329 | t := NewType(fVariant, 8, 8); |
| 322 | 330 | tag := 0; maxSize := 8; lastC := nil; |
| 323 | 331 | while tok = sIdent do begin |
| @@ -335,7 +343,7 @@ | ||
| 335 | 343 | repeat |
| 336 | 344 | n := 0; |
| 337 | 345 | repeat |
| 338 | - if tok <> sIdent then MarkAt(MissingPos, 'name expected'); | |
| 346 | + if tok <> sIdent then Expected('a name'); | |
| 339 | 347 | f := NewObj(oField, id, nil); |
| 340 | 348 | f^.exported := true; |
| 341 | 349 | if lastF = nil then c^.fields := f else lastF^.next := f; |
| @@ -345,7 +353,7 @@ | ||
| 345 | 353 | if tok <> sComma then break; |
| 346 | 354 | Next; |
| 347 | 355 | until false; |
| 348 | - Expect(sColon, ':'); | |
| 356 | + Expect(sColon); | |
| 349 | 357 | ft := ParseType; |
| 350 | 358 | f := c^.fields; |
| 351 | 359 | while f^.typ <> nil do f := f^.next; |
| @@ -360,13 +368,13 @@ | ||
| 360 | 368 | if tok <> sSemicolon then break; |
| 361 | 369 | Next; |
| 362 | 370 | until false; |
| 363 | - Expect(sRparen, ')'); | |
| 371 | + Expect(sRparen); | |
| 364 | 372 | end; |
| 365 | 373 | if off > maxSize then maxSize := off; |
| 366 | - Expect(sSemicolon, ';'); | |
| 374 | + Expect(sSemicolon); | |
| 367 | 375 | inc(tag); |
| 368 | 376 | end; |
| 369 | - Expect(sEnd, 'end'); | |
| 377 | + Expect(sEnd); | |
| 370 | 378 | t^.len := tag; |
| 371 | 379 | t^.size := AlignUp(maxSize, t^.align); |
| 372 | 380 | VariantType := t; |
| @@ -394,7 +402,7 @@ | ||
| 394 | 402 | if tok <> sComma then break; |
| 395 | 403 | Next; |
| 396 | 404 | until false; |
| 397 | - Expect(sRparen, ')'); | |
| 405 | + Expect(sRparen); | |
| 398 | 406 | t^.size := AlignUp(off, t^.align); |
| 399 | 407 | if t^.len = 1 then Results := t^.fields^.typ else Results := t; |
| 400 | 408 | end; |
| @@ -417,7 +425,7 @@ | ||
| 417 | 425 | if isVar then Next; |
| 418 | 426 | first := nil; |
| 419 | 427 | repeat |
| 420 | - if tok <> sIdent then MarkAt(MissingPos, 'name expected'); | |
| 428 | + if tok <> sIdent then Expected('a name'); | |
| 421 | 429 | p := NewObj(oVar, id, nil); |
| 422 | 430 | p^.isVar := isVar; |
| 423 | 431 | p^.lev := 1; |
| @@ -429,13 +437,13 @@ | ||
| 429 | 437 | if tok <> sComma then break; |
| 430 | 438 | Next; |
| 431 | 439 | until false; |
| 432 | - Expect(sColon, ':'); | |
| 440 | + Expect(sColon); | |
| 433 | 441 | pt := ParseType; |
| 434 | 442 | while first <> nil do begin first^.typ := pt; first := first^.next end; |
| 435 | 443 | if tok <> sSemicolon then break; |
| 436 | 444 | Next; |
| 437 | 445 | until false; |
| 438 | - Expect(sRparen, ')'); | |
| 446 | + Expect(sRparen); | |
| 439 | 447 | end; |
| 440 | 448 | t^.len := n; |
| 441 | 449 | if tok = sColon then begin |
| @@ -453,7 +461,7 @@ | ||
| 453 | 461 | last := nil; |
| 454 | 462 | repeat |
| 455 | 463 | Next; |
| 456 | - if tok <> sIdent then MarkAt(MissingPos, 'name expected'); | |
| 464 | + if tok <> sIdent then Expected('a name'); | |
| 457 | 465 | o := NewObj(oConst, id, t); |
| 458 | 466 | o^.val := t^.len; |
| 459 | 467 | o^.exported := declExported; |
| @@ -463,15 +471,15 @@ | ||
| 463 | 471 | inc(t^.len); |
| 464 | 472 | Next; |
| 465 | 473 | 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'); | |
| 468 | 476 | EnumType := t; |
| 469 | 477 | end; |
| 470 | 478 | |
| 471 | 479 | function SetOf(e: PType; const at: TPos): PType; |
| 472 | 480 | var t: PType; |
| 473 | 481 | 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)); | |
| 475 | 483 | t := NewType(fSet, 8, 8); |
| 476 | 484 | if e^.len <= 8 then t^.size := 1 |
| 477 | 485 | else if e^.len <= 16 then t^.size := 2 |
| @@ -489,7 +497,7 @@ | ||
| 489 | 497 | case tok of |
| 490 | 498 | sIdent: begin |
| 491 | 499 | 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'); | |
| 493 | 501 | t := o^.typ; |
| 494 | 502 | end; |
| 495 | 503 | sLbrak: begin |
| @@ -501,8 +509,8 @@ | ||
| 501 | 509 | end else begin |
| 502 | 510 | start := TokPos; |
| 503 | 511 | 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); | |
| 506 | 514 | t := NewType(fArray, 0, 1); |
| 507 | 515 | t^.len := n; |
| 508 | 516 | t^.base := ParseType(); |
| @@ -518,7 +526,7 @@ | ||
| 518 | 526 | { a type declared later in this section } |
| 519 | 527 | t := NewPtr(nil, vol); |
| 520 | 528 | 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'); | |
| 522 | 530 | fwdTypes[numFwd] := t; |
| 523 | 531 | fwdPos[numFwd] := TokPos; |
| 524 | 532 | inc(numFwd); |
| @@ -532,11 +540,11 @@ | ||
| 532 | 540 | sLparen: t := EnumType; |
| 533 | 541 | sSet: begin |
| 534 | 542 | Next; |
| 535 | - Expect(sOf, 'of'); | |
| 543 | + Expect(sOf); | |
| 536 | 544 | start := TokPos; |
| 537 | 545 | t := SetOf(ParseType(), start); |
| 538 | 546 | end; |
| 539 | - else MarkAt(MissingPos, 'type expected'); | |
| 547 | + else Expected('a type'); | |
| 540 | 548 | end; |
| 541 | 549 | ParseType := t; |
| 542 | 550 | end; |
| @@ -547,7 +555,7 @@ | ||
| 547 | 555 | var c: TCall; a: TItem; want: PType; |
| 548 | 556 | begin |
| 549 | 557 | BeginCall(c, x); |
| 550 | - Expect(sLparen, '('); | |
| 558 | + Expect(sLparen); | |
| 551 | 559 | if tok <> sRparen then |
| 552 | 560 | repeat |
| 553 | 561 | if c.param <> nil then want := c.param^.typ else want := nil; |
| @@ -556,7 +564,7 @@ | ||
| 556 | 564 | if tok <> sComma then break; |
| 557 | 565 | Next; |
| 558 | 566 | until false; |
| 559 | - Expect(sRparen, ')'); | |
| 567 | + Expect(sRparen); | |
| 560 | 568 | EndCall(c, x); |
| 561 | 569 | end; |
| 562 | 570 | |
| @@ -564,9 +572,9 @@ | ||
| 564 | 572 | var i: longint; a: TItem; |
| 565 | 573 | begin |
| 566 | 574 | for i := 0 to n - 1 do begin |
| 567 | - if i > 0 then Expect(sComma, ','); | |
| 575 | + if i > 0 then Expect(sComma); | |
| 568 | 576 | 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)); | |
| 570 | 578 | if a.typ^.form = fConst then Coerce(a, tI64); |
| 571 | 579 | slots[i] := ToSlot(a); |
| 572 | 580 | end; |
| @@ -576,14 +584,14 @@ | ||
| 576 | 584 | var p, a: TItem; t: PType; s: array[0..2] of int64; i, n: longint; |
| 577 | 585 | begin |
| 578 | 586 | 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)); | |
| 580 | 588 | t := p.typ^.base; |
| 581 | 589 | 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)); | |
| 583 | 591 | s[0] := ToSlot(p); |
| 584 | 592 | if which = bCas then n := 2 else n := 1; |
| 585 | 593 | for i := 1 to n do begin |
| 586 | - Expect(sComma, ','); | |
| 594 | + Expect(sComma); | |
| 587 | 595 | Expression(a, t); |
| 588 | 596 | Coerce(a, t); |
| 589 | 597 | s[i] := ToSlot(a); |
| @@ -613,11 +621,11 @@ | ||
| 613 | 621 | if (x.mode <> mVar) or not x.isVar or (x.typ^.form <> fPtr) then MarkAt(x.pos, 'NEW needs a pointer variable'); |
| 614 | 622 | t := x.typ^.base; |
| 615 | 623 | Save(x); |
| 616 | - Expect(sComma, ','); | |
| 624 | + Expect(sComma); | |
| 617 | 625 | Expression(y, nil); |
| 618 | 626 | if (y.typ^.form <> fPtr) or (y.typ^.base^.obj = nil) or (y.typ^.base^.obj^.module = nil) |
| 619 | 627 | 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)); | |
| 621 | 629 | f := Find(y.typ^.base^.scope, Name('alloc')); |
| 622 | 630 | s := ToSlot(y); |
| 623 | 631 | Load(RAX, Mem(RBP, s), 8, false); |
| @@ -649,13 +657,18 @@ | ||
| 649 | 657 | x.mode := mNone; |
| 650 | 658 | end; |
| 651 | 659 | |
| 660 | +function IncOrDec(which: longint): shortstring; | |
| 661 | +begin | |
| 662 | + if which = bDec then IncOrDec := 'DEC' else IncOrDec := 'INC'; | |
| 663 | +end; | |
| 664 | + | |
| 652 | 665 | procedure Builtin(var x: TItem); |
| 653 | 666 | const SysRegs: array[0..6] of longint = (RAX, RDI, RSI, RDX, R10, R8, R9); |
| 654 | 667 | var which, n, i: longint; y: TItem; t: PType; slots: array[0..6] of int64; |
| 655 | 668 | begin |
| 656 | 669 | which := x.obj^.val; |
| 657 | 670 | 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; | |
| 659 | 672 | MakeConst(x, tNone, 0); |
| 660 | 673 | case which of |
| 661 | 674 | bFence: begin Mfence; x.mode := mNone end; |
| @@ -664,7 +677,7 @@ | ||
| 664 | 677 | end; |
| 665 | 678 | exit; |
| 666 | 679 | end; |
| 667 | - Expect(sLparen, '('); | |
| 680 | + Expect(sLparen); | |
| 668 | 681 | case which of |
| 669 | 682 | bSize: begin |
| 670 | 683 | t := ParseType; |
| @@ -687,7 +700,7 @@ | ||
| 687 | 700 | Load(RAX, Mem(RAX, 8), 8, false); |
| 688 | 701 | MakeConst(x, tI64, 0); |
| 689 | 702 | 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)); | |
| 691 | 704 | end; |
| 692 | 705 | bSyscall: begin |
| 693 | 706 | n := 1; |
| @@ -695,7 +708,7 @@ | ||
| 695 | 708 | while (tok = sComma) and (n < 7) do begin |
| 696 | 709 | Next; |
| 697 | 710 | 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)); | |
| 699 | 712 | if y.typ^.form = fConst then Coerce(y, tI64); |
| 700 | 713 | slots[n] := ToSlot(y); |
| 701 | 714 | inc(n); |
| @@ -710,7 +723,7 @@ | ||
| 710 | 723 | bInc, bDec: begin |
| 711 | 724 | Expression(x, nil); |
| 712 | 725 | 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'); | |
| 714 | 727 | Save(x); |
| 715 | 728 | if tok = sComma then begin |
| 716 | 729 | Next; |
| @@ -722,7 +735,7 @@ | ||
| 722 | 735 | end; |
| 723 | 736 | bNew: New_(x); |
| 724 | 737 | end; |
| 725 | - Expect(sRparen, ')'); | |
| 738 | + Expect(sRparen); | |
| 726 | 739 | end; |
| 727 | 740 | |
| 728 | 741 | procedure ConstructCase(var x: TItem; c: PObj; const at: TPos); |
| @@ -736,9 +749,9 @@ | ||
| 736 | 749 | Expression(a, f^.typ); |
| 737 | 750 | SetField(x, f, a); |
| 738 | 751 | f := f^.next; |
| 739 | - if f <> nil then Expect(sComma, ','); | |
| 752 | + if f <> nil then Expect(sComma); | |
| 740 | 753 | end; |
| 741 | - Expect(sRparen, ')'); | |
| 754 | + Expect(sRparen); | |
| 742 | 755 | end else if f <> nil then MarkAt(at, NameOf(c^.name) + ' needs its fields'); |
| 743 | 756 | end; |
| 744 | 757 | |
| @@ -750,7 +763,7 @@ | ||
| 750 | 763 | start := TokPos; |
| 751 | 764 | o := QualIdent; |
| 752 | 765 | 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'); | |
| 754 | 767 | MakeItem(x, o); |
| 755 | 768 | if x.mode = mBuiltin then begin |
| 756 | 769 | Builtin(x); |
| @@ -763,12 +776,12 @@ | ||
| 763 | 776 | case tok of |
| 764 | 777 | sPeriod: begin |
| 765 | 778 | 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'); | |
| 768 | 781 | 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)); | |
| 770 | 783 | 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'); | |
| 772 | 785 | Next; |
| 773 | 786 | Field(x, f); |
| 774 | 787 | called := false; |
| @@ -784,7 +797,7 @@ | ||
| 784 | 797 | Expression(z, nil); |
| 785 | 798 | Slice(x, y, z); |
| 786 | 799 | end else Index(x, y); |
| 787 | - Expect(sRbrak, ']'); | |
| 800 | + Expect(sRbrak); | |
| 788 | 801 | called := false; |
| 789 | 802 | end; |
| 790 | 803 | sLparen: begin |
| @@ -792,9 +805,10 @@ | ||
| 792 | 805 | t := x.typ; |
| 793 | 806 | Next; |
| 794 | 807 | Expression(x, nil); |
| 795 | - Expect(sRparen, ')'); | |
| 808 | + Expect(sRparen); | |
| 796 | 809 | Convert(x, t); |
| 797 | 810 | end else begin |
| 811 | + if x.mode = mProc then lastCalled := x.obj else lastCalled := nil; | |
| 798 | 812 | Call(x); |
| 799 | 813 | called := true; |
| 800 | 814 | end; |
| @@ -819,7 +833,7 @@ | ||
| 819 | 833 | n := 0; |
| 820 | 834 | if tok <> sRbrak then |
| 821 | 835 | 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'); | |
| 823 | 837 | Expression(e, et); |
| 824 | 838 | Coerce(e, et); |
| 825 | 839 | if IsScalar(et) then slots[n] := ToSlot(e) |
| @@ -831,8 +845,8 @@ | ||
| 831 | 845 | if tok <> sComma then break; |
| 832 | 846 | Next; |
| 833 | 847 | 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)); | |
| 836 | 850 | if n = 0 then begin |
| 837 | 851 | MovRI(RAX, 0); |
| 838 | 852 | SliceOf(x, want, 0); |
| @@ -870,40 +884,44 @@ | ||
| 870 | 884 | n := 0; |
| 871 | 885 | if tok <> sRbrace then |
| 872 | 886 | repeat |
| 873 | - if tok <> sIdent then MarkAt(MissingPos, 'field expected'); | |
| 887 | + if tok <> sIdent then Expected('a field'); | |
| 874 | 888 | 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'); | |
| 878 | 893 | if n <= High(seen) then begin seen[n] := id; inc(n) end; |
| 879 | 894 | Next; |
| 880 | - Expect(sColon, ':'); | |
| 895 | + Expect(sColon); | |
| 881 | 896 | Expression(a, f^.typ); |
| 882 | 897 | SetField(x, f, a); |
| 883 | 898 | if tok <> sComma then break; |
| 884 | 899 | Next; |
| 885 | 900 | until false; |
| 886 | - Expect(sRbrace, '}'); | |
| 901 | + Expect(sRbrace); | |
| 887 | 902 | end; |
| 888 | 903 | |
| 889 | 904 | { A set literal: the bits of the constant names, or'd at run time with |
| 890 | 905 | those of the others. } |
| 891 | 906 | 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; | |
| 893 | 908 | begin |
| 894 | 909 | start := TokPos; |
| 895 | 910 | 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)); | |
| 897 | 912 | bits := 0; |
| 898 | 913 | slot := 0; |
| 899 | 914 | if tok <> sRbrace then |
| 900 | 915 | repeat |
| 901 | 916 | if t = nil then Expression(e, nil) else Expression(e, t^.base); |
| 902 | 917 | 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)); | |
| 904 | 919 | t := SetOf(e.typ, e.pos); |
| 905 | 920 | 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; | |
| 907 | 925 | if e.mode = mConst then bits := bits or (int64(1) shl e.val) |
| 908 | 926 | else begin |
| 909 | 927 | if slot = 0 then begin |
| @@ -921,7 +939,7 @@ | ||
| 921 | 939 | if tok <> sComma then break; |
| 922 | 940 | Next; |
| 923 | 941 | until false; |
| 924 | - Expect(sRbrace, '}'); | |
| 942 | + Expect(sRbrace); | |
| 925 | 943 | if t = nil then MarkAt(SpanFrom(start), '{} needs a known set type'); |
| 926 | 944 | MakeConst(x, t, bits); |
| 927 | 945 | if slot <> 0 then begin |
| @@ -933,7 +951,7 @@ | ||
| 933 | 951 | end; |
| 934 | 952 | |
| 935 | 953 | 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; | |
| 937 | 955 | begin |
| 938 | 956 | start := TokPos; |
| 939 | 957 | case tok of |
| @@ -946,10 +964,16 @@ | ||
| 946 | 964 | sString: begin MakeStr(x); Next end; |
| 947 | 965 | sIdent: begin |
| 948 | 966 | 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; | |
| 951 | 975 | end; |
| 952 | - sLparen: begin Next; Expression(x, want); Expect(sRparen, ')') end; | |
| 976 | + sLparen: begin Next; Expression(x, want); Expect(sRparen) end; | |
| 953 | 977 | sNot: begin Next; Factor(x, nil); NotOp(x) end; |
| 954 | 978 | sLbrak: ArrayLiteral(x, want); |
| 955 | 979 | sLbrace: if (want <> nil) and (want^.form = fRecord) then RecordLiteral(x, want) |
| @@ -959,12 +983,12 @@ | ||
| 959 | 983 | vol := tok = sVolatile; |
| 960 | 984 | if vol then Next; |
| 961 | 985 | t := NewPtr(ParseType, vol); |
| 962 | - Expect(sLparen, '('); | |
| 986 | + Expect(sLparen); | |
| 963 | 987 | Expression(x, nil); |
| 964 | - Expect(sRparen, ')'); | |
| 988 | + Expect(sRparen); | |
| 965 | 989 | Convert(x, t); |
| 966 | 990 | end; |
| 967 | - else MarkAt(MissingPos, 'expression expected'); | |
| 991 | + else Expected('an expression'); | |
| 968 | 992 | end; |
| 969 | 993 | x.pos := SpanFrom(start); |
| 970 | 994 | end; |
| @@ -1040,7 +1064,7 @@ | ||
| 1040 | 1064 | begin |
| 1041 | 1065 | Next; |
| 1042 | 1066 | Expression(x, nil); |
| 1043 | - Expect(sThen, 'then'); | |
| 1067 | + Expect(sThen); | |
| 1044 | 1068 | L := NoLabel; |
| 1045 | 1069 | CondJump(x, L); |
| 1046 | 1070 | Statements; |
| @@ -1050,7 +1074,7 @@ | ||
| 1050 | 1074 | FixLink(L); |
| 1051 | 1075 | Next; |
| 1052 | 1076 | Expression(x, nil); |
| 1053 | - Expect(sThen, 'then'); | |
| 1077 | + Expect(sThen); | |
| 1054 | 1078 | L := NoLabel; |
| 1055 | 1079 | CondJump(x, L); |
| 1056 | 1080 | Statements; |
| @@ -1061,7 +1085,7 @@ | ||
| 1061 | 1085 | Next; |
| 1062 | 1086 | Statements; |
| 1063 | 1087 | end else FixLink(L); |
| 1064 | - Expect(sEnd, 'end'); | |
| 1088 | + Expect(sEnd); | |
| 1065 | 1089 | FixLink(endL); |
| 1066 | 1090 | end; |
| 1067 | 1091 | |
| @@ -1071,13 +1095,13 @@ | ||
| 1071 | 1095 | Next; |
| 1072 | 1096 | top := pc; |
| 1073 | 1097 | Expression(x, nil); |
| 1074 | - Expect(sDo, 'do'); | |
| 1098 | + Expect(sDo); | |
| 1075 | 1099 | L := NoLabel; |
| 1076 | 1100 | CondJump(x, L); |
| 1077 | 1101 | Loop(lp, old); |
| 1078 | 1102 | Statements; |
| 1079 | 1103 | JmpBack(top); |
| 1080 | - Expect(sEnd, 'end'); | |
| 1104 | + Expect(sEnd); | |
| 1081 | 1105 | FixLink(L); |
| 1082 | 1106 | FixLink(lp.brk); |
| 1083 | 1107 | curLoop := old; |
| @@ -1091,7 +1115,7 @@ | ||
| 1091 | 1115 | Loop(lp, old); |
| 1092 | 1116 | Statements; |
| 1093 | 1117 | curLoop := old; |
| 1094 | - Expect(sUntil, 'until'); | |
| 1118 | + Expect(sUntil); | |
| 1095 | 1119 | Expression(x, nil); |
| 1096 | 1120 | L := NoLabel; |
| 1097 | 1121 | CondJump(x, L); |
| @@ -1105,17 +1129,20 @@ | ||
| 1105 | 1129 | lp: TLoop; old: PLoop; |
| 1106 | 1130 | begin |
| 1107 | 1131 | Next; |
| 1108 | - if tok <> sIdent then MarkAt(MissingPos, 'name expected'); | |
| 1132 | + if tok <> sIdent then Expected('a name'); | |
| 1109 | 1133 | 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'); | |
| 1112 | 1139 | Next; |
| 1113 | - Expect(sBecomes, ':='); | |
| 1140 | + Expect(sBecomes); | |
| 1114 | 1141 | MakeItem(v, o); |
| 1115 | 1142 | Save(v); |
| 1116 | 1143 | Expression(a, o^.typ); |
| 1117 | 1144 | Assign(v, a); |
| 1118 | - Expect(sTo, 'to'); | |
| 1145 | + Expect(sTo); | |
| 1119 | 1146 | Expression(b, o^.typ); |
| 1120 | 1147 | Coerce(b, o^.typ); |
| 1121 | 1148 | bslot := ToSlot(b); |
| @@ -1126,7 +1153,7 @@ | ||
| 1126 | 1153 | step := ConstValue(s); |
| 1127 | 1154 | if step = 0 then MarkAt(s.pos, 'the step can''t be zero'); |
| 1128 | 1155 | end; |
| 1129 | - Expect(sDo, 'do'); | |
| 1156 | + Expect(sDo); | |
| 1130 | 1157 | exitL := NoLabel; |
| 1131 | 1158 | top := pc; |
| 1132 | 1159 | MakeItem(v, o); |
| @@ -1141,7 +1168,7 @@ | ||
| 1141 | 1168 | Loop(lp, old); |
| 1142 | 1169 | Statements; |
| 1143 | 1170 | curLoop := old; |
| 1144 | - Expect(sEnd, 'end'); | |
| 1171 | + Expect(sEnd); | |
| 1145 | 1172 | ForNext(o, bslot, step, exitL, top); |
| 1146 | 1173 | FixLink(exitL); |
| 1147 | 1174 | FixLink(lp.brk); |
| @@ -1156,7 +1183,7 @@ | ||
| 1156 | 1183 | Expression(x, nil); |
| 1157 | 1184 | p := MatchBegin(x); |
| 1158 | 1185 | t := x.typ; |
| 1159 | - Expect(sOf, 'of'); | |
| 1186 | + Expect(sOf); | |
| 1160 | 1187 | FillChar(seen, SizeOf(seen), 0); |
| 1161 | 1188 | hasElse := false; |
| 1162 | 1189 | endL := NoLabel; |
| @@ -1165,15 +1192,15 @@ | ||
| 1165 | 1192 | if hasElse then Mark('else must be the last arm'); |
| 1166 | 1193 | if tok = sElse then begin |
| 1167 | 1194 | Next; |
| 1168 | - Expect(sColon, ':'); | |
| 1195 | + Expect(sColon); | |
| 1169 | 1196 | Statements; |
| 1170 | 1197 | hasElse := true; |
| 1171 | 1198 | end else begin |
| 1172 | - if tok <> sIdent then MarkAt(MissingPos, 'case expected'); | |
| 1199 | + if tok <> sIdent then Expected('a case'); | |
| 1173 | 1200 | c := t^.fields; |
| 1174 | 1201 | while (c <> nil) and (c^.name <> id) do c := c^.next; |
| 1175 | 1202 | 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'); | |
| 1177 | 1204 | if c^.val <= High(seen) then seen[c^.val] := true; |
| 1178 | 1205 | Next; |
| 1179 | 1206 | L := NoLabel; |
| @@ -1184,8 +1211,8 @@ | ||
| 1184 | 1211 | f := c^.fields; |
| 1185 | 1212 | n := 0; |
| 1186 | 1213 | 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'); | |
| 1189 | 1216 | o := NewObj(oVar, id, f^.typ); |
| 1190 | 1217 | o^.lev := 1; o^.ind := true; o^.isVar := true; |
| 1191 | 1218 | o^.val := p; o^.off := f^.val; |
| @@ -1196,10 +1223,10 @@ | ||
| 1196 | 1223 | if tok <> sComma then break; |
| 1197 | 1224 | Next; |
| 1198 | 1225 | 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); | |
| 1201 | 1228 | end; |
| 1202 | - Expect(sColon, ':'); | |
| 1229 | + Expect(sColon); | |
| 1203 | 1230 | Statements; |
| 1204 | 1231 | CloseScope; |
| 1205 | 1232 | Jmp(endL); |
| @@ -1207,7 +1234,7 @@ | ||
| 1207 | 1234 | end; |
| 1208 | 1235 | end; |
| 1209 | 1236 | endAt := TokPos; |
| 1210 | - Expect(sEnd, 'end'); | |
| 1237 | + Expect(sEnd); | |
| 1211 | 1238 | if not hasElse then begin |
| 1212 | 1239 | c := t^.fields; |
| 1213 | 1240 | while c <> nil do begin |
| @@ -1218,26 +1245,37 @@ | ||
| 1218 | 1245 | FixLink(endL); |
| 1219 | 1246 | end; |
| 1220 | 1247 | |
| 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 | + | |
| 1221 | 1257 | { a, b := f(x): the variables first, left to right, then the call; |
| 1222 | 1258 | 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; | |
| 1225 | 1261 | begin |
| 1226 | 1262 | n := 0; |
| 1227 | 1263 | d[0] := x; |
| 1264 | + dn[0] := first; | |
| 1228 | 1265 | 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])); | |
| 1230 | 1267 | Pin(d[n]); |
| 1231 | 1268 | inc(n); |
| 1232 | 1269 | 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'); | |
| 1234 | 1271 | Next; |
| 1272 | + dn[n] := id; | |
| 1235 | 1273 | Designator(d[n], called); |
| 1236 | 1274 | until false; |
| 1237 | - Expect(sBecomes, ':='); | |
| 1275 | + Expect(sBecomes); | |
| 1238 | 1276 | Designator(y, called); |
| 1239 | 1277 | 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'); | |
| 1241 | 1279 | f := y.typ^.fields; |
| 1242 | 1280 | for i := 0 to n - 1 do begin |
| 1243 | 1281 | z := y; |
| @@ -1255,7 +1293,7 @@ | ||
| 1255 | 1293 | Expression(x, f^.typ); |
| 1256 | 1294 | ReturnField(f, x); |
| 1257 | 1295 | f := f^.next; |
| 1258 | - if f <> nil then Expect(sComma, ','); | |
| 1296 | + if f <> nil then Expect(sComma); | |
| 1259 | 1297 | end; |
| 1260 | 1298 | end; |
| 1261 | 1299 | |
| @@ -1267,7 +1305,7 @@ | ||
| 1267 | 1305 | start := TokPos; |
| 1268 | 1306 | Next; |
| 1269 | 1307 | 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'); | |
| 1271 | 1309 | L := NoLabel; |
| 1272 | 1310 | Jmp(L); |
| 1273 | 1311 | pos := pc; |
| @@ -1287,27 +1325,28 @@ | ||
| 1287 | 1325 | end; |
| 1288 | 1326 | |
| 1289 | 1327 | 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; | |
| 1291 | 1329 | begin |
| 1292 | 1330 | start := TokPos; |
| 1331 | + first := id; | |
| 1293 | 1332 | NoteLine(CurLine); |
| 1294 | 1333 | m := TempMark; |
| 1295 | 1334 | case tok of |
| 1296 | 1335 | sIdent: begin |
| 1297 | 1336 | Designator(x, called); |
| 1298 | 1337 | 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)); | |
| 1300 | 1339 | Save(x); |
| 1301 | 1340 | Next; |
| 1302 | 1341 | Expression(y, x.typ); |
| 1303 | 1342 | Assign(x, y); |
| 1304 | 1343 | end else if tok = sComma then |
| 1305 | - MultiAssign(x) | |
| 1344 | + MultiAssign(x, first) | |
| 1306 | 1345 | else if not called then begin |
| 1307 | 1346 | if (x.mode = mProc) or ((x.mode in [mVar, mReg]) and (x.typ^.form = fProc)) then begin |
| 1308 | 1347 | BeginCall(c, x); |
| 1309 | 1348 | 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'); | |
| 1311 | 1350 | end; |
| 1312 | 1351 | end; |
| 1313 | 1352 | sIf: IfStatement; |
| @@ -1343,8 +1382,8 @@ | ||
| 1343 | 1382 | Jmp(curLoop^.brk); |
| 1344 | 1383 | end; |
| 1345 | 1384 | 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'); | |
| 1348 | 1387 | end; |
| 1349 | 1388 | ReleaseTemps(m); |
| 1350 | 1389 | end; |
| @@ -1375,7 +1414,7 @@ | ||
| 1375 | 1414 | directDefer := false; |
| 1376 | 1415 | while not (tok in [sEnd, sElse, sElsif, sUntil, sBar, sEof]) do begin |
| 1377 | 1416 | Statement; |
| 1378 | - if not skipped or (tok = sSemicolon) then Expect(sSemicolon, ';'); | |
| 1417 | + if not skipped or (tok = sSemicolon) then Expect(sSemicolon); | |
| 1379 | 1418 | end; |
| 1380 | 1419 | RunDefers(base); |
| 1381 | 1420 | numDefers := base; |
| @@ -1399,7 +1438,7 @@ | ||
| 1399 | 1438 | dec(d); |
| 1400 | 1439 | if (d = 0) and sawBegin then begin Next; exit end; |
| 1401 | 1440 | end; |
| 1402 | - sEof: Mark('end expected'); | |
| 1441 | + sEof: Expected('"end"'); | |
| 1403 | 1442 | end; |
| 1404 | 1443 | Next; |
| 1405 | 1444 | until false; |
| @@ -1430,13 +1469,13 @@ | ||
| 1430 | 1469 | o := q; |
| 1431 | 1470 | end; |
| 1432 | 1471 | Declarations(false); |
| 1433 | - Expect(sBegin, 'begin'); | |
| 1472 | + Expect(sBegin); | |
| 1434 | 1473 | old := curResult; |
| 1435 | 1474 | curResult := sig^.base; |
| 1436 | 1475 | EnterBody(p^.chunk, line); |
| 1437 | 1476 | Statements; |
| 1438 | 1477 | NoteLine(CurLine); |
| 1439 | - Expect(sEnd, 'end'); | |
| 1478 | + Expect(sEnd); | |
| 1440 | 1479 | EndProc(p^.chunk); |
| 1441 | 1480 | curResult := old; |
| 1442 | 1481 | CloseScope; |
| @@ -1466,7 +1505,7 @@ | ||
| 1466 | 1505 | repeat |
| 1467 | 1506 | start := TokPos; |
| 1468 | 1507 | 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)); | |
| 1470 | 1509 | Put1(v); |
| 1471 | 1510 | if tok <> sComma then break; |
| 1472 | 1511 | Next; |
| @@ -1483,11 +1522,11 @@ | ||
| 1483 | 1522 | IdentDef(n, exp); |
| 1484 | 1523 | at := SpanFrom(at); |
| 1485 | 1524 | sig := Signature; |
| 1486 | - Expect(sSemicolon, ';'); | |
| 1525 | + Expect(sSemicolon); | |
| 1487 | 1526 | p := Find(TopScope, n); |
| 1488 | 1527 | 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'); | |
| 1491 | 1530 | p^.exported := p^.exported or exp; |
| 1492 | 1531 | end else begin |
| 1493 | 1532 | p := NewObj(oProc, n, sig); |
| @@ -1511,7 +1550,7 @@ | ||
| 1511 | 1550 | end; |
| 1512 | 1551 | if checkMode then SkipBody else Body(p, sig, line); |
| 1513 | 1552 | 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)); | |
| 1515 | 1554 | Next; |
| 1516 | 1555 | end; |
| 1517 | 1556 | end; |
| @@ -1541,11 +1580,11 @@ | ||
| 1541 | 1580 | if (t^.base <> nil) and not IsScalar(t^.base) then MarkAt(at, 'C returns a single value'); |
| 1542 | 1581 | o := NewObj(oProc, n, t); |
| 1543 | 1582 | end else begin |
| 1544 | - if tok <> sVar then MarkAt(MissingPos, 'proc or var expected'); | |
| 1583 | + if tok <> sVar then Expected('"proc" or "var"'); | |
| 1545 | 1584 | Next; |
| 1546 | 1585 | IdentDef(n, exp); |
| 1547 | 1586 | WillDeclare(n); |
| 1548 | - Expect(sColon, ':'); | |
| 1587 | + Expect(sColon); | |
| 1549 | 1588 | declExported := exp; |
| 1550 | 1589 | t := ParseType; |
| 1551 | 1590 | declExported := false; |
| @@ -1569,7 +1608,7 @@ | ||
| 1569 | 1608 | t := ParseType; |
| 1570 | 1609 | if t <> tError then MarkAt(SpanFrom(start), 'only an ERROR constant has a type'); |
| 1571 | 1610 | end; |
| 1572 | - Expect(sEql, '='); | |
| 1611 | + Expect(sEql); | |
| 1573 | 1612 | Expression(x, nil); |
| 1574 | 1613 | o := NewObj(oConst, n, x.typ); |
| 1575 | 1614 | o^.exported := exp and top; |
| @@ -1579,7 +1618,7 @@ | ||
| 1579 | 1618 | end else if x.mode = mStr then begin o^.val := x.val; o^.chunk := x.chunk end |
| 1580 | 1619 | else o^.val := ConstValue(x); |
| 1581 | 1620 | Declare(o); |
| 1582 | - Expect(sSemicolon, ';'); | |
| 1621 | + Expect(sSemicolon); | |
| 1583 | 1622 | end; |
| 1584 | 1623 | |
| 1585 | 1624 | procedure TypeDecl(top: boolean); |
| @@ -1587,7 +1626,7 @@ | ||
| 1587 | 1626 | begin |
| 1588 | 1627 | IdentDef(n, exp); |
| 1589 | 1628 | WillDeclare(n); |
| 1590 | - Expect(sEql, '='); | |
| 1629 | + Expect(sEql); | |
| 1591 | 1630 | declExported := exp and top; |
| 1592 | 1631 | inTypes := true; |
| 1593 | 1632 | t := ParseType; |
| @@ -1595,7 +1634,7 @@ | ||
| 1595 | 1634 | o^.exported := exp and top; |
| 1596 | 1635 | if t^.obj = nil then t^.obj := o; |
| 1597 | 1636 | Declare(o); |
| 1598 | - Expect(sSemicolon, ';'); | |
| 1637 | + Expect(sSemicolon); | |
| 1599 | 1638 | end; |
| 1600 | 1639 | |
| 1601 | 1640 | procedure VarDecl(top: boolean); |
| @@ -1605,14 +1644,14 @@ | ||
| 1605 | 1644 | begin |
| 1606 | 1645 | k := 0; |
| 1607 | 1646 | 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'); | |
| 1609 | 1648 | IdentDef(names[k], exps[k]); |
| 1610 | 1649 | WillDeclare(names[k]); |
| 1611 | 1650 | inc(k); |
| 1612 | 1651 | if tok <> sComma then break; |
| 1613 | 1652 | Next; |
| 1614 | 1653 | until false; |
| 1615 | - Expect(sColon, ':'); | |
| 1654 | + Expect(sColon); | |
| 1616 | 1655 | declExported := top and exps[0]; |
| 1617 | 1656 | t := ParseType; |
| 1618 | 1657 | declExported := false; |
| @@ -1630,7 +1669,7 @@ | ||
| 1630 | 1669 | end; |
| 1631 | 1670 | Declare(o); |
| 1632 | 1671 | end; |
| 1633 | - Expect(sSemicolon, ';'); | |
| 1672 | + Expect(sSemicolon); | |
| 1634 | 1673 | end; |
| 1635 | 1674 | |
| 1636 | 1675 | { After a procedure had an error: its name is poison if it wasn't |
| @@ -1669,12 +1708,12 @@ | ||
| 1669 | 1708 | sProc: begin |
| 1670 | 1709 | if not top then Mark('procedures don''t nest'); |
| 1671 | 1710 | ProcDecl; |
| 1672 | - Expect(sSemicolon, ';'); | |
| 1711 | + Expect(sSemicolon); | |
| 1673 | 1712 | end; |
| 1674 | 1713 | 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'); | |
| 1676 | 1715 | ExternDecl; |
| 1677 | - Expect(sSemicolon, ';'); | |
| 1716 | + Expect(sSemicolon); | |
| 1678 | 1717 | end; |
| 1679 | 1718 | end |
| 1680 | 1719 | else begin |
| @@ -1736,18 +1775,18 @@ | ||
| 1736 | 1775 | end; |
| 1737 | 1776 | |
| 1738 | 1777 | { The arguments of an instance: types, or procedures named. } |
| 1739 | -procedure ParseArgs(var args: TArgs); | |
| 1778 | +procedure ParseArgs(var args: TArgs; const mname: shortstring); | |
| 1740 | 1779 | var o: PObj; start: TPos; |
| 1741 | 1780 | begin |
| 1742 | 1781 | Next; |
| 1743 | 1782 | 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); | |
| 1745 | 1784 | args.o[args.n] := nil; |
| 1746 | 1785 | start := TokPos; |
| 1747 | 1786 | if tok = sIdent then begin |
| 1748 | 1787 | o := QualIdent; |
| 1749 | 1788 | 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'); | |
| 1751 | 1790 | args.t[args.n] := o^.typ; |
| 1752 | 1791 | end else args.t[args.n] := ParseType; |
| 1753 | 1792 | args.pos[args.n] := SpanFrom(start); |
| @@ -1755,7 +1794,7 @@ | ||
| 1755 | 1794 | if tok <> sComma then break; |
| 1756 | 1795 | Next; |
| 1757 | 1796 | until false; |
| 1758 | - Expect(sRparen, ')'); | |
| 1797 | + Expect(sRparen); | |
| 1759 | 1798 | end; |
| 1760 | 1799 | |
| 1761 | 1800 | { A generic module's parameters, bound to the instance's arguments: a |
| @@ -1767,8 +1806,9 @@ | ||
| 1767 | 1806 | s := NameOf(m^.name) + '('; |
| 1768 | 1807 | Next; |
| 1769 | 1808 | 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)); | |
| 1772 | 1812 | Declare(NewObj(oType, id, m^.args.t[i])); |
| 1773 | 1813 | s := s + TypeName(m^.args.t[i]) + ','; |
| 1774 | 1814 | inc(i); |
| @@ -1778,17 +1818,18 @@ | ||
| 1778 | 1818 | until false; |
| 1779 | 1819 | while tok = sSemicolon do begin |
| 1780 | 1820 | Next; |
| 1781 | - if tok <> sIdent then MarkAt(MissingPos, 'name expected'); | |
| 1821 | + if tok <> sIdent then Expected('a name'); | |
| 1782 | 1822 | at := TokPos; |
| 1783 | 1823 | o := NewObj(oProc, id, nil); |
| 1784 | 1824 | Next; |
| 1785 | - Expect(sColon, ':'); | |
| 1786 | - Expect(sProc, 'proc'); | |
| 1825 | + Expect(sColon); | |
| 1826 | + Expect(sProc); | |
| 1787 | 1827 | 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)); | |
| 1789 | 1829 | 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)); | |
| 1792 | 1833 | Note(at, NameOf(o^.name) + ' is declared here'); |
| 1793 | 1834 | Finish; |
| 1794 | 1835 | end; |
| @@ -1797,8 +1838,8 @@ | ||
| 1797 | 1838 | s := s + NameOf(a^.module^.name) + '.' + NameOf(a^.name) + ','; |
| 1798 | 1839 | inc(i); |
| 1799 | 1840 | 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)); | |
| 1802 | 1843 | s[length(s)] := ')'; |
| 1803 | 1844 | m^.sname := Name(s); |
| 1804 | 1845 | end; |
| @@ -1839,22 +1880,22 @@ | ||
| 1839 | 1880 | fileChunk := -1; |
| 1840 | 1881 | checkMode := checkOnly; |
| 1841 | 1882 | 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'); | |
| 1843 | 1884 | pending[numPending] := m; |
| 1844 | 1885 | inc(numPending); |
| 1845 | 1886 | end; |
| 1846 | 1887 | OpenScope(m^.scope); |
| 1847 | 1888 | 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); | |
| 1850 | 1891 | Next; |
| 1851 | 1892 | if tok = sLparen then Params(m) |
| 1852 | 1893 | else if args.n > 0 then MarkAt(args.at, NameOf(n) + ' isn''t generic'); |
| 1853 | - Expect(sSemicolon, ';'); | |
| 1894 | + Expect(sSemicolon); | |
| 1854 | 1895 | while tok = sImport do begin |
| 1855 | 1896 | Next; |
| 1856 | 1897 | repeat |
| 1857 | - if tok <> sIdent then MarkAt(MissingPos, 'module name expected'); | |
| 1898 | + if tok <> sIdent then Expected('a module name'); | |
| 1858 | 1899 | start := TokPos; |
| 1859 | 1900 | alias := id; |
| 1860 | 1901 | mname := id; |
| @@ -1862,10 +1903,10 @@ | ||
| 1862 | 1903 | Next; |
| 1863 | 1904 | if tok = sBecomes then begin |
| 1864 | 1905 | Next; |
| 1865 | - if tok <> sIdent then MarkAt(MissingPos, 'module name expected'); | |
| 1906 | + if tok <> sIdent then Expected('a module name'); | |
| 1866 | 1907 | mname := id; |
| 1867 | 1908 | Next; |
| 1868 | - if tok = sLparen then ParseArgs(iargs); | |
| 1909 | + if tok = sLparen then ParseArgs(iargs, NameOf(mname)); | |
| 1869 | 1910 | end; |
| 1870 | 1911 | iargs.at := SpanFrom(start); |
| 1871 | 1912 | im := ImportModule(mname, iargs); |
| @@ -1879,7 +1920,7 @@ | ||
| 1879 | 1920 | if tok <> sComma then break; |
| 1880 | 1921 | Next; |
| 1881 | 1922 | until false; |
| 1882 | - Expect(sSemicolon, ';'); | |
| 1923 | + Expect(sSemicolon); | |
| 1883 | 1924 | end; |
| 1884 | 1925 | while tok = sLink do begin |
| 1885 | 1926 | Next; |
| @@ -1890,9 +1931,9 @@ | ||
| 1890 | 1931 | lib^.next := m^.libs; |
| 1891 | 1932 | m^.libs := lib; |
| 1892 | 1933 | m^.usesC := true; |
| 1893 | - end else Mark('a library or static expected'); | |
| 1934 | + end else Expected('a library or "static"'); | |
| 1894 | 1935 | Next; |
| 1895 | - Expect(sSemicolon, ';'); | |
| 1936 | + Expect(sSemicolon); | |
| 1896 | 1937 | end; |
| 1897 | 1938 | Declarations(true); |
| 1898 | 1939 | if tok = sBegin then begin |
| @@ -1908,13 +1949,13 @@ | ||
| 1908 | 1949 | EnterBody(body, line); |
| 1909 | 1950 | Statements; |
| 1910 | 1951 | NoteLine(CurLine); |
| 1911 | - Expect(sEnd, 'end'); | |
| 1952 | + Expect(sEnd); | |
| 1912 | 1953 | EndProc(body); |
| 1913 | 1954 | 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)); | |
| 1916 | 1957 | Next; |
| 1917 | - if tok <> sPeriod then MarkAt(MissingPos, '. expected'); | |
| 1958 | + if tok <> sPeriod then Expected('"."'); | |
| 1918 | 1959 | o := m^.first; |
| 1919 | 1960 | while o <> nil do begin |
| 1920 | 1961 | if (o^.cls = oProc) and o^.fwd then Error(TokPos, NameOf(o^.name) + ' is declared forward but never defined'); |
| @@ -66,7 +66,7 @@ | ||
| 66 | 66 | seen := false; |
| 67 | 67 | for i := 0 to numNeeded - 1 do seen := seen or (needed[i] = l^.name); |
| 68 | 68 | 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'); | |
| 70 | 70 | needed[numNeeded] := l^.name; |
| 71 | 71 | inc(numNeeded); |
| 72 | 72 | end; |
| @@ -107,7 +107,7 @@ | ||
| 107 | 107 | s := ParamStr(i); |
| 108 | 108 | if s = '-I' then begin |
| 109 | 109 | 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'); | |
| 111 | 111 | incDirs[numInc] := ParamStr(i); |
| 112 | 112 | inc(numInc); |
| 113 | 113 | end else if s = '-o' then begin |
| @@ -70,7 +70,10 @@ | ||
| 70 | 70 | procedure Next; |
| 71 | 71 | procedure Mark(const msg: shortstring); |
| 72 | 72 | procedure MarkAt(const p: TPos; const msg: shortstring); |
| 73 | +procedure MarkHelp(const p: TPos; const msg, hint: shortstring); | |
| 73 | 74 | function AtLineStart: boolean; |
| 75 | +function SymText(s: TSym): shortstring; | |
| 76 | +function Found: shortstring; | |
| 74 | 77 | |
| 75 | 78 | var |
| 76 | 79 | { Where the parser goes on after an error: the innermost statement or |
| @@ -100,6 +103,10 @@ | ||
| 100 | 103 | 'in', 'link', 'match', 'mod', 'module', 'not', 'of', 'or', 'packed', |
| 101 | 104 | 'proc', 'record', 'repeat', 'return', 'set', 'shl', 'shr', 'then', |
| 102 | 105 | 'to', 'type', 'until', 'var', 'variant', 'VOLATILE', 'while', 'xor'); |
| 106 | + Ops: array[sPlus..sBar] of string[3] = ( | |
| 107 | + '+', '-', '*', '/', '=', '#', '<', '<=', '>', '>=', | |
| 108 | + ':=', ':', ';', ',', '.', '..', '...', | |
| 109 | + '(', ')', '[', ']', '{', '}', '^', '|'); | |
| 103 | 110 | |
| 104 | 111 | var |
| 105 | 112 | cur: TScanState; { buf .. path; tok, ival, rval and id live above } |
| @@ -239,6 +246,14 @@ | ||
| 239 | 246 | longjmp(recovery^, 1); |
| 240 | 247 | end; |
| 241 | 248 | |
| 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 | + | |
| 242 | 257 | { An error in the text at bytes a to b of the file being read, which |
| 243 | 258 | stops the compiler: past it, the symbols can't be trusted. } |
| 244 | 259 | procedure MarkBytes(a, b: longint; const msg: shortstring); |
| @@ -254,6 +269,27 @@ | ||
| 254 | 269 | MarkBytes(cur.tokPos, cur.pos, msg); |
| 255 | 270 | end; |
| 256 | 271 | |
| 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 | + | |
| 257 | 293 | { The current symbol is the first on its line: at the top level of a |
| 258 | 294 | module, by the usual layout, so where reading can start again. } |
| 259 | 295 | function AtLineStart: boolean; |
| @@ -324,7 +360,7 @@ | ||
| 324 | 360 | $F4: begin n := 3; cp := 4; hi := $8F end; { up to 10FFFFH } |
| 325 | 361 | else |
| 326 | 362 | cur.tokPos := pos; |
| 327 | - LexError('bad UTF-8'); | |
| 363 | + LexError('invalid UTF-8'); | |
| 328 | 364 | end; |
| 329 | 365 | for i := 1 to n do begin |
| 330 | 366 | b1 := byte(cur.buf[pos + i]); |
| @@ -341,7 +377,7 @@ | ||
| 341 | 377 | |
| 342 | 378 | procedure Put(b: longint); |
| 343 | 379 | begin |
| 344 | - if slen >= MaxStr then LexError('string too long'); | |
| 380 | + if slen >= MaxStr then LexError('a string holds at most ' + IntStr(MaxStr) + ' bytes'); | |
| 345 | 381 | sbuf[slen] := b; |
| 346 | 382 | inc(slen); |
| 347 | 383 | end; |
| @@ -369,10 +405,19 @@ | ||
| 369 | 405 | end; |
| 370 | 406 | end; |
| 371 | 407 | |
| 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 | + | |
| 372 | 417 | { One character of a character or string literal, at buf[pos]: its code |
| 373 | 418 | point, or for \xHH, minus one minus the byte. } |
| 374 | 419 | function LitChar(inString: boolean): longint; |
| 375 | -var c: char; v, d, n, esc: longint; | |
| 420 | +var c: char; v, d, n, esc, digits: longint; | |
| 376 | 421 | begin |
| 377 | 422 | c := cur.buf[cur.pos]; |
| 378 | 423 | esc := cur.pos; |
| @@ -387,7 +432,7 @@ | ||
| 387 | 432 | '0': v := 0; |
| 388 | 433 | '\', '''', '"': v := ord(c); |
| 389 | 434 | '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'); | |
| 391 | 436 | d := HexVal(cur.buf[cur.pos]); |
| 392 | 437 | n := HexVal(cur.buf[cur.pos + 1]); |
| 393 | 438 | if (d < 0) or (n < 0) then MarkBytes(esc, cur.pos + 2, '\x needs two hex digits'); |
| @@ -395,25 +440,27 @@ | ||
| 395 | 440 | v := -1 - (d * 16 + n); |
| 396 | 441 | end; |
| 397 | 442 | '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'); | |
| 399 | 444 | inc(cur.pos); |
| 445 | + digits := cur.pos; | |
| 400 | 446 | v := 0; n := 0; |
| 401 | 447 | while HexVal(cur.buf[cur.pos]) >= 0 do begin |
| 402 | 448 | v := v * 16 + HexVal(cur.buf[cur.pos]); |
| 403 | 449 | 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'); | |
| 405 | 451 | 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{'); | |
| 407 | 453 | inc(cur.pos); |
| 408 | 454 | 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'); | |
| 410 | 456 | end; |
| 411 | - else MarkBytes(esc, cur.pos, 'unknown escape'); | |
| 457 | + else MarkBytes(esc, cur.pos, 'unknown escape \' + c); | |
| 412 | 458 | end; |
| 413 | 459 | end else if byte(c) >= $80 then |
| 414 | 460 | v := Utf8(cur.pos) |
| 415 | 461 | 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') | |
| 417 | 464 | else begin |
| 418 | 465 | v := ord(c); |
| 419 | 466 | inc(cur.pos); |
| @@ -459,40 +506,41 @@ | ||
| 459 | 506 | if cur.buf[cur.pos] = 'H' then begin |
| 460 | 507 | v := 0; |
| 461 | 508 | 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'); | |
| 463 | 510 | v := v * 16 + qword(HexVal(cur.buf[i])); |
| 464 | 511 | end; |
| 465 | 512 | inc(cur.pos); |
| 466 | 513 | tok := sInt; |
| 467 | 514 | ival := int64(v); { 16 digits are the bits of a 64-bit word } |
| 468 | 515 | 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'); | |
| 470 | 517 | inc(cur.pos); |
| 471 | 518 | while cur.buf[cur.pos] in ['0'..'9'] do inc(cur.pos); |
| 472 | 519 | if cur.buf[cur.pos] = 'E' then begin |
| 473 | 520 | inc(cur.pos); |
| 474 | 521 | 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'); | |
| 476 | 523 | while cur.buf[cur.pos] in ['0'..'9'] do inc(cur.pos); |
| 477 | 524 | 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'); | |
| 479 | 526 | SetLength(s, cur.pos - start); |
| 480 | 527 | Move(cur.buf[start], s[1], cur.pos - start); |
| 481 | 528 | 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'); | |
| 483 | 530 | tok := sReal; |
| 484 | 531 | 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'); | |
| 486 | 533 | v := 0; |
| 487 | 534 | for i := start to cur.pos - 1 do begin |
| 488 | 535 | 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'); | |
| 490 | 537 | v := v * 10 + qword(d); |
| 491 | 538 | end; |
| 492 | 539 | tok := sInt; |
| 493 | 540 | ival := int64(v); |
| 494 | 541 | 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'); | |
| 496 | 544 | end; |
| 497 | 545 | |
| 498 | 546 | procedure Next; |
| @@ -520,7 +568,7 @@ | ||
| 520 | 568 | start := cur.pos; |
| 521 | 569 | repeat inc(cur.pos) |
| 522 | 570 | 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'); | |
| 524 | 572 | h := Intern(@cur.buf[start], cur.pos - start); |
| 525 | 573 | if h < NumWords then tok := TSym(ord(sAnd) + h) |
| 526 | 574 | else begin tok := sIdent; id := h end; |
| @@ -586,13 +634,13 @@ | ||
| 586 | 634 | '^': begin inc(cur.pos); tok := sArrow end; |
| 587 | 635 | '|': begin inc(cur.pos); tok := sBar end; |
| 588 | 636 | #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'); | |
| 590 | 638 | tok := sEof; |
| 591 | 639 | end; |
| 592 | 640 | else |
| 593 | 641 | 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 + '"'); | |
| 596 | 644 | end; |
| 597 | 645 | end; |
| 598 | 646 |
| @@ -199,7 +199,7 @@ | ||
| 199 | 199 | |
| 200 | 200 | procedure OpenScope(s: longint); |
| 201 | 201 | begin |
| 202 | - if depth = MaxDepth then Mark('nested too deeply'); | |
| 202 | + if depth = MaxDepth then Mark('scopes nested more than ' + IntStr(MaxDepth) + ' deep'); | |
| 203 | 203 | scopes[depth] := s; |
| 204 | 204 | inc(depth); |
| 205 | 205 | end; |
| @@ -306,7 +306,7 @@ | ||
| 306 | 306 | |
| 307 | 307 | function Mem(base: longint; disp: int64): TMem; |
| 308 | 308 | 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'); | |
| 310 | 310 | Mem.base := base; Mem.index := NoIndex; Mem.scale := 1; |
| 311 | 311 | Mem.disp := disp; Mem.chunk := -1; |
| 312 | 312 | end; |
| @@ -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 | |
| 2 | 2 | 5 | b := b and (x + 1); |
| 3 | 3 | | ^^^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | x := x(1); |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | if x + 1 then end; |
| 3 | 3 | | ^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | x := 5 + 3000000000; |
| 3 | 3 | | ^^^^^^^^^^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | y := x^; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | x := a[b]; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | x := a[2 + 3]; |
| 3 | 3 | | ^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 7 | x := Id(1, 2 * 3); |
| 3 | 3 | | ^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | match x + 1 do end; |
| 3 | 3 | | ^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | b := not s; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | x := I64 + 1; |
| 3 | 3 | | ^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 2 | var a: [0]I64; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 3 | code 300; |
| 3 | 3 | | ^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 7 | a, k := two(); |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -1,4 +1,4 @@ | ||
| 1 | -test/err/AtPChar.raz:5:12: error: unexpected character | |
| 1 | +test/err/AtPChar.raz:5:12: error: unexpected character "?" | |
| 2 | 2 | 5 | a := 1 ? 2; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 4 | var a: [n]I64; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | a := [1, 2]; |
| 3 | 3 | | ^^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | s := "a\q"; |
| 3 | 3 | | ^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | INC(a); |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | a := LEN(a); |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 8 | a := p() + 1; |
| 3 | 3 | | ^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | a := a.f; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | a; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 6 | s := {r, 1}; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | x := p - q; |
| 3 | 3 | | ^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | s := a[0..b]; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 5 | s := a[b..2]; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 2 | import Str, M := Map([]U8, I64, Str.cmp, Str.eq); |
| 3 | 3 | | ^^^^^^^ |
| 4 | 4 | lib/Map.raz:4:18: note: hash is declared here |
| @@ -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 |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module DeclArrayUnknown; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + if [1] = [1] then end; | |
| 5 | +end; | |
| 6 | +end DeclArrayUnknown. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module DeclIntConst; | |
| 2 | +proc main*; | |
| 3 | +var a: [1.5]I64; | |
| 4 | +begin | |
| 5 | +end; | |
| 6 | +end DeclIntConst. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module DeclSetType; | |
| 2 | +proc main*; | |
| 3 | +var s: set of I64; | |
| 4 | +begin | |
| 5 | +end; | |
| 6 | +end DeclSetType. |
| @@ -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 |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module DeclSetUnknown; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + if {} = {} then end; | |
| 5 | +end; | |
| 6 | +end DeclSetUnknown. |
| @@ -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 |
| @@ -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. |
| @@ -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 | |
| 2 | 2 | 5 | if A < B then end; |
| 3 | 3 | | ^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 6 | i.extra := 1; |
| 3 | 3 | | ^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module GenErrorString; | |
| 2 | +const E: ERROR = 1; | |
| 3 | +proc main*; | |
| 4 | +begin | |
| 5 | + | |
| 6 | +end; | |
| 7 | +end GenErrorString. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/GenFrame.raz:7:4: error: frame too big | |
| 2 | + 7 | end; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module GenFrame; | |
| 2 | + | |
| 3 | +proc main*; | |
| 4 | +var a: [3000000000]U8; | |
| 5 | +begin | |
| 6 | + | |
| 7 | +end; | |
| 8 | +end GenFrame. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/GenTooFewValue.raz:6:8: error: too few arguments | |
| 2 | + 6 | f(); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 | |
| 2 | 2 | 5 | u := -1; |
| 3 | 3 | | ^^ |
| 4 | 4 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 2 | import List; |
| 3 | 3 | | ^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -19,10 +19,10 @@ | ||
| 19 | 19 | test/err/Recover.raz:22:12: error: can't combine I64 and BOOL |
| 20 | 20 | 22 | return x + true; |
| 21 | 21 | | ^^^^^^^^ |
| 22 | -test/err/Recover.raz:28:7: error: no field c | |
| 22 | +test/err/Recover.raz:28:7: error: Q has no field c | |
| 23 | 23 | 28 | q.c := 1; |
| 24 | 24 | | ^ |
| 25 | -test/err/Recover.raz:30:18: error: ; expected | |
| 25 | +test/err/Recover.raz:30:18: error: expected ";", found "return" | |
| 26 | 26 | 30 | Out.str("hi") |
| 27 | 27 | | ^ |
| 28 | 28 | test/err/Recover.raz:37:13: error: nope isn't declared |
| @@ -1,19 +1,19 @@ | ||
| 1 | -test/err/Resync.raz:10:5: error: ; expected | |
| 1 | +test/err/Resync.raz:10:5: error: expected ";", found a | |
| 2 | 2 | 10 | end a; |
| 3 | 3 | | ^ |
| 4 | -test/err/Resync.raz:14:31: error: ; expected | |
| 4 | +test/err/Resync.raz:14:31: error: expected ";", found "end" | |
| 5 | 5 | 14 | while x > 0 do x := x - 1 end; |
| 6 | 6 | | ^^^ |
| 7 | -test/err/Resync.raz:15:10: error: expression expected | |
| 7 | +test/err/Resync.raz:15:10: error: expected an expression, found ")" | |
| 8 | 8 | 15 | x := ) + 2; |
| 9 | 9 | | ^ |
| 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 | |
| 11 | 11 | 16 | match x |
| 12 | 12 | | ^ |
| 13 | -test/err/Resync.raz:23:13: error: expression expected | |
| 13 | +test/err/Resync.raz:23:13: error: expected an expression, found ";" | |
| 14 | 14 | 23 | x := 1 +; |
| 15 | 15 | | ^ |
| 16 | -test/err/Resync.raz:23:14: error: end expected | |
| 16 | +test/err/Resync.raz:23:14: error: expected "end", found "proc" | |
| 17 | 17 | 23 | x := 1 +; |
| 18 | 18 | | ^ |
| 19 | 19 | test/err/Resync.raz:27:10: error: can't use BOOL as I64 |
| @@ -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 |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ScanBigDec; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; | |
| 4 | +begin | |
| 5 | + x := 9223372036854775808; | |
| 6 | +end; | |
| 7 | +end ScanBigDec. |
| @@ -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 |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ScanBigHex; | |
| 2 | +proc main*; | |
| 3 | +var x: U64; | |
| 4 | +begin | |
| 5 | + x := 10000000000000000H; | |
| 6 | +end; | |
| 7 | +end ScanBigHex. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/ScanCharEmpty.raz:5:10: error: empty character | |
| 2 | + 5 | c := ''; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ScanCharEmpty; | |
| 2 | +proc main*; | |
| 3 | +var c: U8; | |
| 4 | +begin | |
| 5 | + c := ''; | |
| 6 | +end; | |
| 7 | +end ScanCharEmpty. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/ScanCharOpen.raz:5:10: error: character not closed | |
| 2 | + 5 | c := 'ab'; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ScanCharOpen; | |
| 2 | +proc main*; | |
| 3 | +var c: U8; | |
| 4 | +begin | |
| 5 | + c := 'ab'; | |
| 6 | +end; | |
| 7 | +end ScanCharOpen. |
| @@ -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 |
| @@ -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. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/ScanComment.raz:4:5: error: comment not closed | |
| 2 | + 4 | (* never closed | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module ScanComment; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + (* never closed | |
| 5 | +end; | |
| 6 | +end ScanComment. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ScanHexChar; | |
| 2 | +proc main*; | |
| 3 | +var c: U8; | |
| 4 | +begin | |
| 5 | + c := '\x41'; | |
| 6 | +end; | |
| 7 | +end ScanHexChar. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ScanHexH; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; | |
| 4 | +begin | |
| 5 | + x := 12A; | |
| 6 | +end; | |
| 7 | +end ScanHexH. |
| @@ -0,0 +1 @@ | ||
| 1 | +raz: main must be proc main* or proc main*: I64 |
| @@ -0,0 +1,5 @@ | ||
| 1 | +module ScanMain; | |
| 2 | +proc main*(n: I64); | |
| 3 | +begin | |
| 4 | +end; | |
| 5 | +end ScanMain. |
| @@ -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 |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module ScanName; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; | |
| 5 | +end; | |
| 6 | +end ScanName. |
| @@ -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 |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ScanNameDigit; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; | |
| 4 | +begin | |
| 5 | + x := 12abc; | |
| 6 | +end; | |
| 7 | +end ScanNameDigit. |
Binary file; the patch has it.
Binary file; the patch has it.
| @@ -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 |
| @@ -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. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/ScanStringOpen.raz:5:10: error: string not closed | |
| 2 | + 5 | s := "abc; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/ScanUBrace.raz:5:11: error: expected "{" after \u | |
| 2 | + 5 | s := "\u0041"; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -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. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/ScanUtf8.raz:5:11: error: invalid UTF-8 | |
| 2 | + 5 | s := "ÿ"; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ScanUtf8; | |
| 2 | +proc main*; | |
| 3 | +var s: [4]U8; | |
| 4 | +begin | |
| 5 | + s := "ÿ"; | |
| 6 | +end; | |
| 7 | +end ScanUtf8. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtArgKind; | |
| 2 | +import Mem, L := List(Mem.Page); | |
| 3 | +end StmtArgKind. |
| @@ -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 |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module StmtAssignConst; | |
| 2 | +const k = 1; | |
| 3 | +proc main*; | |
| 4 | +begin | |
| 5 | + k := 2; | |
| 6 | +end; | |
| 7 | +end StmtAssignConst. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,4 @@ | ||
| 1 | +module StmtCReturns; | |
| 2 | +type R = record a: I64; end; | |
| 3 | +extern proc f(): R; | |
| 4 | +end StmtCReturns. |
| @@ -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 |
| @@ -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. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/StmtCaseTwice.raz:12:7: error: dot has two arms | |
| 2 | + 12 | | dot: | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,4 @@ | ||
| 1 | +module StmtCodeParams; | |
| 2 | +proc f(a, b, c, d, e, f, g: I64); | |
| 3 | +code 0C3H; | |
| 4 | +end StmtCodeParams. |
| @@ -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 |
| @@ -0,0 +1,5 @@ | ||
| 1 | +module StmtCodeResult; | |
| 2 | +type R = record a: I64; end; | |
| 3 | +proc f: R; | |
| 4 | +code 0C3H; | |
| 5 | +end StmtCodeResult. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,4 @@ | ||
| 1 | +module StmtCodeTwo; | |
| 2 | +proc f: (F64, I64); | |
| 3 | +code 0C3H; | |
| 4 | +end StmtCodeTwo. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/StmtDot.raz:2:12: error: expected ".", found ";" | |
| 2 | + 2 | end StmtDot; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,2 @@ | ||
| 1 | +module StmtDot; | |
| 2 | +end StmtDot; |
| @@ -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 |
| @@ -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. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +test/err/StmtEnd.raz:5:12: error: expected "end", found ")" | |
| 2 | + 5 | a := 1; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,2 @@ | ||
| 1 | +module StmtEndName; | |
| 2 | +end Other. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtErrType; | |
| 2 | +const k: I64 = "a"; | |
| 3 | +end StmtErrType. |
| @@ -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 |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module StmtExternLocal; | |
| 2 | +proc main*; | |
| 3 | + extern proc f; | |
| 4 | +begin | |
| 5 | +end; | |
| 6 | +end StmtExternLocal. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,4 @@ | ||
| 1 | +module StmtForwardTwice; | |
| 2 | +proc f; forward; | |
| 3 | +proc f; forward; | |
| 4 | +end StmtForwardTwice. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtFwdPtr; | |
| 2 | +type P = ^Missing; | |
| 3 | +end StmtFwdPtr. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtImportName; | |
| 2 | +import 5; | |
| 3 | +end StmtImportName. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtLibrary; | |
| 2 | +link 5; | |
| 3 | +end StmtLibrary. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtManyTypeArgs; | |
| 2 | +import L := List(I64, I64); | |
| 3 | +end StmtManyTypeArgs. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtNeedProc; | |
| 2 | +import Str, M := Map([]U8, I64, I64, Str.eq); | |
| 3 | +end StmtNeedProc. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtNeedType; | |
| 2 | +import Str, M := Map(Str.cmp, I64, Str.cmp, Str.eq); | |
| 3 | +end StmtNeedType. |
| @@ -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 |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module StmtNest; | |
| 2 | +proc main*; | |
| 3 | + proc inner; forward; | |
| 4 | +begin | |
| 5 | +end; | |
| 6 | +end StmtNest. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtNeverDefined; | |
| 2 | +proc f; forward; | |
| 3 | +end StmtNeverDefined. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtNoModule; | |
| 2 | +import Nothing; | |
| 3 | +end StmtNoModule. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtParamName; | |
| 2 | +import L := StmtParam(I64); | |
| 3 | +end StmtParamName. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtProcName; | |
| 2 | +proc main*; begin end mian; | |
| 3 | +end StmtProcName. |
| @@ -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 |
| @@ -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. |
| @@ -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 |
| @@ -0,0 +1,4 @@ | ||
| 1 | +module StmtSigForward; | |
| 2 | +proc f(a: I64); forward; | |
| 3 | +proc f(a: BOOL); begin end; | |
| 4 | +end StmtSigForward. |
| @@ -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 |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module StmtStatement; | |
| 2 | +proc main*; | |
| 3 | +var a: I64; | |
| 4 | +begin | |
| 5 | + a := 1; ) | |
| 6 | +end; | |
| 7 | +end StmtStatement. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtVarOrProc; | |
| 2 | +extern 5; | |
| 3 | +end StmtVarOrProc. |
| @@ -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 |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtWrongModule; | |
| 2 | +import StmtOther; | |
| 3 | +end StmtWrongModule. |
| @@ -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 | |
| 2 | 2 | 6 | a := two() + 1; |
| 3 | 3 | | ^^^^^ |
| 4 | +help: they go to variables: a, b := two(...) | |
| 4 | 5 | raz: 1 error |
| @@ -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 | |
| 2 | 2 | 2 | var é: I64; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +module DeclHidden; | |
| 2 | +const shown* = 1; | |
| 3 | +const hidden = 2; | |
| 4 | +end DeclHidden. |
| @@ -0,0 +1,2 @@ | ||
| 1 | +module StmtWrong; | |
| 2 | +end StmtWrong. |
| @@ -0,0 +1,2 @@ | ||
| 1 | +module StmtParam(5); | |
| 2 | +end StmtParam. |