One wording for two types that don't mix; constants shown as written "I32 and I64 are different types", with help on converting when both are numbers, replaces "different types: ..." and "can't combine ...". "/" on integers says it divides reals, not integers, and shows the same division with div. A constant without a type of its own is named as written: "found 1.5", not "found a real constant".
| @@ -8,11 +8,11 @@ | ||
| 8 | 8 | |
| 9 | 9 | | File | Lines | Code | What | |
| 10 | 10 | |---|---|---|---| |
| 11 | -| `src/diag.pas` | 249 | 178 | Messages: positions, source excerpts, colour, counts | | |
| 12 | -| `src/scan.pas` | 660 | 529 | Symbols, literals, comments, positions | | |
| 11 | +| `src/diag.pas` | 260 | 187 | Messages: positions, source excerpts, colour, counts | | |
| 12 | +| `src/scan.pas` | 659 | 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,492 | 1,303 | Items: loading, storing, copying, frames, calls | | |
| 15 | +| `src/gen.pas` | 1,512 | 1,318 | Items: loading, storing, copying, frames, calls | | |
| 16 | 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 | |
| @@ -233,7 +233,9 @@ | ||
| 233 | 233 | An item also carries `pos`, the stretch of source it came from, which |
| 234 | 234 | the parser sets as it reads an expression; an error about an item is |
| 235 | 235 | reported there (`MarkAt(x.pos, ...)`), and one about two operands |
| 236 | -across both (`Join(x.pos, y.pos)`). | |
| 236 | +across both (`Join(x.pos, y.pos)`). `What` names an item for a | |
| 237 | +message: a constant without a type of its own as it is written | |
| 238 | +(`found 1.5`), anything else by its type. | |
| 237 | 239 | |
| 238 | 240 | Three routines move items towards the machine. `Value` brings a value |
| 239 | 241 | into `rax`, loading it with the one instruction its size needs. |
| @@ -37,6 +37,7 @@ | ||
| 37 | 37 | function PathOf(f: longint): shortstring; |
| 38 | 38 | function LineOf(const p: TPos): longint; |
| 39 | 39 | function Join(const p, q: TPos): TPos; |
| 40 | +function Source(const p: TPos): shortstring; | |
| 40 | 41 | procedure Error(const p: TPos; const msg: shortstring); |
| 41 | 42 | procedure Warning(const p: TPos; const msg: shortstring); |
| 42 | 43 | procedure Note(const p: TPos; const msg: shortstring); |
| @@ -185,6 +186,16 @@ | ||
| 185 | 186 | begin |
| 186 | 187 | Join := p; |
| 187 | 188 | Join.b := q.b; |
| 189 | +end; | |
| 190 | + | |
| 191 | +{ The text at p, at most the 255 bytes a shortstring holds } | |
| 192 | +function Source(const p: TPos): shortstring; | |
| 193 | +var n: longint; | |
| 194 | +begin | |
| 195 | + n := p.b - p.a; | |
| 196 | + if n > 255 then n := 255; | |
| 197 | + SetLength(Source, n); | |
| 198 | + Move(files[p.f].buf[p.a], Source[1], n); | |
| 188 | 199 | end; |
| 189 | 200 | |
| 190 | 201 | { Messages } |
| @@ -66,6 +66,7 @@ | ||
| 66 | 66 | depth: longint; { values pushed and not yet popped } |
| 67 | 67 | |
| 68 | 68 | procedure MakeConst(var x: TItem; t: PType; v: int64); |
| 69 | +function What(const x: TItem): shortstring; | |
| 69 | 70 | procedure MakeReal(var x: TItem; r: double); |
| 70 | 71 | procedure MakeStr(var x: TItem); |
| 71 | 72 | procedure MakeItem(var x: TItem; o: PObj); |
| @@ -201,6 +202,25 @@ | ||
| 201 | 202 | SetData(x.chunk, @sbuf, slen + 1, 1); |
| 202 | 203 | end; |
| 203 | 204 | |
| 205 | +{ An item for "found ...": a constant without a type of its own as it | |
| 206 | + is written, so that "found 1.5" says what is wrong; else its type. } | |
| 207 | +function What(const x: TItem): shortstring; | |
| 208 | +begin | |
| 209 | + if (x.mode = mConst) and ((x.typ = tConst) or (x.typ = tRConst)) then What := Source(x.pos) | |
| 210 | + else What := TypeName(x.typ); | |
| 211 | +end; | |
| 212 | + | |
| 213 | +{ Two operands of different types. Numbers convert, so say how. } | |
| 214 | +procedure Mismatch(const x, y: TItem; xt, yt: PType); | |
| 215 | +var msg: shortstring; | |
| 216 | +begin | |
| 217 | + msg := TypeName(xt) + ' and ' + TypeName(yt) + ' are different types'; | |
| 218 | + if (IsInt(xt) or (xt^.form = fReal)) and (IsInt(yt) or (yt^.form = fReal)) | |
| 219 | + and (xt <> tConst) and (xt <> tRConst) then | |
| 220 | + MarkHelp(Join(x.pos, y.pos), msg, 'convert one to the other''s type, as in ' + TypeName(xt) + '(' + Source(y.pos) + ')') | |
| 221 | + else MarkAt(Join(x.pos, y.pos), msg); | |
| 222 | +end; | |
| 223 | + | |
| 204 | 224 | { An item that is not a value, by what it is. } |
| 205 | 225 | procedure NotValue(const x: TItem); |
| 206 | 226 | begin |
| @@ -324,7 +344,7 @@ | ||
| 324 | 344 | |
| 325 | 345 | procedure LoadVar(var x: TItem; r: longint); |
| 326 | 346 | begin |
| 327 | - if not IsScalar(x.typ) then MarkAt(x.pos, 'expected a single value, found ' + TypeName(x.typ)); | |
| 347 | + if not IsScalar(x.typ) then MarkAt(x.pos, 'expected a single value, found ' + What(x)); | |
| 328 | 348 | Load(r, MemOf(x, r), ScalarSize(x.typ), (x.typ^.form = fInt) and x.typ^.signed); |
| 329 | 349 | end; |
| 330 | 350 | |
| @@ -565,7 +585,7 @@ | ||
| 565 | 585 | Value(x); PushRax; x.mode := mStack |
| 566 | 586 | end else if (x.mode = mVar) and (x.typ^.form in [fArray, fSlice]) then |
| 567 | 587 | Save(x) |
| 568 | - else MarkAt(x.pos, 'expected an array, a slice or a pointer, found ' + TypeName(x.typ)); | |
| 588 | + else MarkAt(x.pos, 'expected an array, a slice or a pointer, found ' + What(x)); | |
| 569 | 589 | end; |
| 570 | 590 | |
| 571 | 591 | procedure Index(var x, y: TItem); |
| @@ -573,7 +593,7 @@ | ||
| 573 | 593 | begin |
| 574 | 594 | t := x.typ; |
| 575 | 595 | s := t^.base^.size; |
| 576 | - if not IsInt(y.typ) then MarkAt(y.pos, 'an index is an integer, found ' + TypeName(y.typ)); | |
| 596 | + if not IsInt(y.typ) then MarkAt(y.pos, 'an index is an integer, found ' + What(y)); | |
| 577 | 597 | if t^.form = fPtr then begin |
| 578 | 598 | Value(y); |
| 579 | 599 | if s <> 1 then ImulI(RAX, s); |
| @@ -611,7 +631,7 @@ | ||
| 611 | 631 | |
| 612 | 632 | procedure SliceLo(var lo: TItem); |
| 613 | 633 | begin |
| 614 | - if not IsInt(lo.typ) then MarkAt(lo.pos, 'an index is an integer, found ' + TypeName(lo.typ)); | |
| 634 | + if not IsInt(lo.typ) then MarkAt(lo.pos, 'an index is an integer, found ' + What(lo)); | |
| 615 | 635 | Value(lo); |
| 616 | 636 | PushRax; |
| 617 | 637 | end; |
| @@ -621,7 +641,7 @@ | ||
| 621 | 641 | begin |
| 622 | 642 | t := x.typ; |
| 623 | 643 | s := t^.base^.size; |
| 624 | - if not IsInt(hi.typ) then MarkAt(hi.pos, 'an index is an integer, found ' + TypeName(hi.typ)); | |
| 644 | + if not IsInt(hi.typ) then MarkAt(hi.pos, 'an index is an integer, found ' + What(hi)); | |
| 625 | 645 | if x.vol then MarkAt(x.pos, 'can''t make a slice through a volatile pointer'); |
| 626 | 646 | Value(hi); |
| 627 | 647 | MovRR(RDX, RAX); |
| @@ -676,7 +696,7 @@ | ||
| 676 | 696 | end else if IsInt(x.typ) then begin |
| 677 | 697 | if x.mode = mConst then x.val := Cut(not x.val, x.typ) |
| 678 | 698 | else begin Value(x); Unary(2, RAX); Norm(x.typ) end; |
| 679 | - end else MarkAt(x.pos, '"not" needs a BOOL or an integer, found ' + TypeName(x.typ)); | |
| 699 | + end else MarkAt(x.pos, '"not" needs a BOOL or an integer, found ' + What(x)); | |
| 680 | 700 | end; |
| 681 | 701 | |
| 682 | 702 | function IsStrLike(t: PType): boolean; |
| @@ -815,7 +835,7 @@ | ||
| 815 | 835 | if y.mode in [mType, mBuiltin, mNone, mCase] then NotValue(y); |
| 816 | 836 | |
| 817 | 837 | if (op in [sAnd, sOr]) and (xt^.form = fBool) then begin |
| 818 | - if yt^.form <> fBool then MarkAt(y.pos, SymText(op) + ' needs BOOLs, found ' + TypeName(yt)); | |
| 838 | + if yt^.form <> fBool then MarkAt(y.pos, SymText(op) + ' needs BOOLs, found ' + What(y)); | |
| 819 | 839 | if (x.mode = mConst) and (y.mode = mConst) then begin |
| 820 | 840 | FixLink(L); |
| 821 | 841 | if op = sAnd then x.val := x.val and y.val else x.val := x.val or y.val; |
| @@ -845,7 +865,7 @@ | ||
| 845 | 865 | { the type of the result, and the checks } |
| 846 | 866 | t := nil; scale := 1; isPtr := false; |
| 847 | 867 | if IsInt(xt) and IsInt(yt) then begin |
| 848 | - if op = sSlash then MarkHelp(Join(x.pos, y.pos), '"/" is for reals, found ' + TypeName(xt), 'integers divide with "div"'); | |
| 868 | + if op = sSlash then MarkHelp(Join(x.pos, y.pos), '"/" divides reals, not integers', 'to divide integers, write ' + Source(x.pos) + ' div ' + Source(y.pos)); | |
| 849 | 869 | if op in [sShl, sShr] then begin |
| 850 | 870 | if xt^.form = fConst then t := tConst else t := xt |
| 851 | 871 | end else if (xt^.form = fConst) and (yt^.form = fConst) then t := tConst |
| @@ -856,12 +876,12 @@ | ||
| 856 | 876 | if (y.mode = mConst) and not Fits(y.val, xt) then MarkAt(y.pos, IntStr(y.val) + ' doesn''t fit ' + TypeName(xt)); |
| 857 | 877 | t := xt |
| 858 | 878 | end else if Same(xt, yt) then t := xt |
| 859 | - else MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt)); | |
| 879 | + else Mismatch(x, y, xt, yt); | |
| 860 | 880 | end else if (xt^.form = fReal) and (yt^.form = fReal) then begin |
| 861 | 881 | if not (op in Rel + [sPlus, sMinus, sTimes, sSlash]) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt)); |
| 862 | 882 | if xt = tRConst then t := yt |
| 863 | 883 | else if (yt = tRConst) or Same(xt, yt) then t := xt |
| 864 | - else MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt)); | |
| 884 | + else Mismatch(x, y, xt, yt); | |
| 865 | 885 | if (x.mode = mConst) and (x.typ <> t) then RealTo(x, t); |
| 866 | 886 | if (y.mode = mConst) and (y.typ <> t) then RealTo(y, t); |
| 867 | 887 | end else if (xt^.form = fBool) and (yt^.form = fBool) then begin |
| @@ -871,7 +891,7 @@ | ||
| 871 | 891 | t := xt; scale := xt^.base^.size; isPtr := true; |
| 872 | 892 | if y.mode = mConst then y.typ := tI64; |
| 873 | 893 | end else if (xt^.form = fPtr) and (yt^.form = fPtr) and (op = sMinus) then begin |
| 874 | - if not Same(xt, yt) then MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt)); | |
| 894 | + if not Same(xt, yt) then Mismatch(x, y, xt, yt); | |
| 875 | 895 | t := tI64; scale := xt^.base^.size; isPtr := true; |
| 876 | 896 | end else if (xt^.form in [fPtr, fProc, fNil, fError]) and (yt^.form in [fPtr, fProc, fNil, fError]) then begin |
| 877 | 897 | if not (op in Rel) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt)); |
| @@ -879,7 +899,7 @@ | ||
| 879 | 899 | if not (op in [sEql, sNeq]) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt)); |
| 880 | 900 | if (xt^.form <> fNil) and (yt^.form <> fNil) and not Same(xt, yt) then |
| 881 | 901 | if not ((xt^.form = fPtr) and (yt^.form = fPtr) and Same(xt^.base, yt^.base)) then |
| 882 | - MarkAt(Join(x.pos, y.pos), 'different types: ' + TypeName(xt) + ' and ' + TypeName(yt)); | |
| 902 | + Mismatch(x, y, xt, yt); | |
| 883 | 903 | t := tU64; |
| 884 | 904 | end else if (xt^.form = fEnum) and Same(xt, yt) then begin |
| 885 | 905 | if not (op in Rel) then MarkAt(Join(x.pos, y.pos), SymText(op) + ' doesn''t apply to ' + TypeName(xt)); |
| @@ -890,7 +910,7 @@ | ||
| 890 | 910 | end else if (op = sIn) and (yt^.form = fSet) and Same(xt, yt^.base) then |
| 891 | 911 | t := yt |
| 892 | 912 | else |
| 893 | - MarkAt(Join(x.pos, y.pos), 'can''t combine ' + TypeName(xt) + ' and ' + TypeName(yt)); | |
| 913 | + Mismatch(x, y, xt, yt); | |
| 894 | 914 | unsign := (t^.form = fInt) and not t^.signed; |
| 895 | 915 | |
| 896 | 916 | { constants } |
| @@ -1087,7 +1107,7 @@ | ||
| 1087 | 1107 | c.obj := x.obj; c.code := x.obj^.isCode; c.ext := x.obj^.ext; |
| 1088 | 1108 | end else begin |
| 1089 | 1109 | 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)); | |
| 1110 | + if x.typ^.form <> fProc then MarkAt(x.pos, 'expected a procedure, found ' + What(x)); | |
| 1091 | 1111 | c.sig := x.typ; c.chunk := -1; |
| 1092 | 1112 | c.target := ToSlot(x); |
| 1093 | 1113 | end; |
| @@ -1121,7 +1141,7 @@ | ||
| 1121 | 1141 | c.isF[c.n] := (p^.typ^.form = fReal) and not p^.isVar; |
| 1122 | 1142 | if p^.isVar then begin |
| 1123 | 1143 | if (a.mode <> mVar) or not a.isVar then MarkAt(a.pos, 'a var parameter needs a variable'); |
| 1124 | - if not Same(a.typ, p^.typ) then MarkAt(a.pos, 'a var parameter needs exactly ' + TypeName(p^.typ) + ', found ' + TypeName(a.typ)); | |
| 1144 | + if not Same(a.typ, p^.typ) then MarkAt(a.pos, 'a var parameter needs exactly ' + TypeName(p^.typ) + ', found ' + What(a)); | |
| 1125 | 1145 | if a.vol then MarkAt(a.pos, 'can''t pass through a volatile pointer to a var parameter'); |
| 1126 | 1146 | Address(a, RAX); |
| 1127 | 1147 | s := AllocTemp(8, 8); |
| @@ -1244,7 +1264,7 @@ | ||
| 1244 | 1264 | var p: int64; |
| 1245 | 1265 | begin |
| 1246 | 1266 | if x.typ^.form = fEnum then exit(ToSlot(x)); |
| 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)); | |
| 1267 | + if (x.mode <> mVar) or (x.typ^.form <> fVariant) then MarkAt(x.pos, 'match needs a variant or an enumeration, found ' + What(x)); | |
| 1248 | 1268 | Address(x, RAX); |
| 1249 | 1269 | p := AllocTemp(8, 8); |
| 1250 | 1270 | Store(Mem(RBP, p), RAX, 8); |
| @@ -1289,7 +1309,7 @@ | ||
| 1289 | 1309 | |
| 1290 | 1310 | procedure CondJump(var x: TItem; var L: longint); |
| 1291 | 1311 | begin |
| 1292 | - if x.typ^.form <> fBool then MarkAt(x.pos, 'a condition is a BOOL, found ' + TypeName(x.typ)); | |
| 1312 | + if x.typ^.form <> fBool then MarkAt(x.pos, 'a condition is a BOOL, found ' + What(x)); | |
| 1293 | 1313 | Value(x); |
| 1294 | 1314 | TestRR(RAX, RAX); |
| 1295 | 1315 | Jcc(ccE, L); |
| @@ -243,7 +243,7 @@ | ||
| 243 | 243 | var x: TItem; |
| 244 | 244 | begin |
| 245 | 245 | Expression(x, nil); |
| 246 | - if not IsInt(x.typ) then MarkAt(x.pos, 'expected an integer constant, found ' + TypeName(x.typ)); | |
| 246 | + if not IsInt(x.typ) then MarkAt(x.pos, 'expected an integer constant, found ' + What(x)); | |
| 247 | 247 | ConstExpr := ConstValue(x); |
| 248 | 248 | end; |
| 249 | 249 | |
| @@ -574,7 +574,7 @@ | ||
| 574 | 574 | for i := 0 to n - 1 do begin |
| 575 | 575 | if i > 0 then Expect(sComma); |
| 576 | 576 | Expression(a, nil); |
| 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)); | |
| 577 | + if not (IsScalar(a.typ) and (a.typ^.form <> fReal)) then MarkAt(a.pos, 'expected an integer or a pointer, found ' + What(a)); | |
| 578 | 578 | if a.typ^.form = fConst then Coerce(a, tI64); |
| 579 | 579 | slots[i] := ToSlot(a); |
| 580 | 580 | end; |
| @@ -584,7 +584,7 @@ | ||
| 584 | 584 | var p, a: TItem; t: PType; s: array[0..2] of int64; i, n: longint; |
| 585 | 585 | begin |
| 586 | 586 | Expression(p, nil); |
| 587 | - if p.typ^.form <> fPtr then MarkAt(p.pos, 'expected a pointer, found ' + TypeName(p.typ)); | |
| 587 | + if p.typ^.form <> fPtr then MarkAt(p.pos, 'expected a pointer, found ' + What(p)); | |
| 588 | 588 | t := p.typ^.base; |
| 589 | 589 | if not (((t^.form = fInt) or ((t^.form = fPtr) and (which <> bXadd))) and (t^.size = 8)) then |
| 590 | 590 | MarkAt(p.pos, 'expected an 8-byte integer or a pointer, found ' + TypeName(t)); |
| @@ -625,7 +625,7 @@ | ||
| 625 | 625 | Expression(y, nil); |
| 626 | 626 | if (y.typ^.form <> fPtr) or (y.typ^.base^.obj = nil) or (y.typ^.base^.obj^.module = nil) |
| 627 | 627 | or (NameOf(y.typ^.base^.obj^.name) <> 'Allocator') |
| 628 | - or (NameOf(y.typ^.base^.obj^.module^.name) <> 'Mem') then MarkAt(y.pos, 'NEW needs a ^Mem.Allocator, found ' + TypeName(y.typ)); | |
| 628 | + or (NameOf(y.typ^.base^.obj^.module^.name) <> 'Mem') then MarkAt(y.pos, 'NEW needs a ^Mem.Allocator, found ' + What(y)); | |
| 629 | 629 | f := Find(y.typ^.base^.scope, Name('alloc')); |
| 630 | 630 | s := ToSlot(y); |
| 631 | 631 | Load(RAX, Mem(RBP, s), 8, false); |
| @@ -700,7 +700,7 @@ | ||
| 700 | 700 | Load(RAX, Mem(RAX, 8), 8, false); |
| 701 | 701 | MakeConst(x, tI64, 0); |
| 702 | 702 | x.mode := mReg; |
| 703 | - end else MarkAt(y.pos, 'LEN needs an array or a slice, found ' + TypeName(y.typ)); | |
| 703 | + end else MarkAt(y.pos, 'LEN needs an array or a slice, found ' + What(y)); | |
| 704 | 704 | end; |
| 705 | 705 | bSyscall: begin |
| 706 | 706 | n := 1; |
| @@ -708,7 +708,7 @@ | ||
| 708 | 708 | while (tok = sComma) and (n < 7) do begin |
| 709 | 709 | Next; |
| 710 | 710 | Expression(y, nil); |
| 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)); | |
| 711 | + if not (IsScalar(y.typ) and (y.typ^.form <> fReal)) then MarkAt(y.pos, 'expected an integer or a pointer, found ' + What(y)); | |
| 712 | 712 | if y.typ^.form = fConst then Coerce(y, tI64); |
| 713 | 713 | slots[n] := ToSlot(y); |
| 714 | 714 | inc(n); |
| @@ -776,7 +776,7 @@ | ||
| 776 | 776 | case tok of |
| 777 | 777 | sPeriod: begin |
| 778 | 778 | Next; |
| 779 | - if (x.mode <> mVar) or (x.typ^.form <> fRecord) then MarkAt(x.pos, 'expected a record, found ' + TypeName(x.typ)); | |
| 779 | + if (x.mode <> mVar) or (x.typ^.form <> fRecord) then MarkAt(x.pos, 'expected a record, found ' + What(x)); | |
| 780 | 780 | if tok <> sIdent then Expected('a field'); |
| 781 | 781 | f := Find(x.typ^.scope, id); |
| 782 | 782 | if f = nil then Mark(TypeName(x.typ) + ' has no field ' + NameOf(id)); |
| @@ -915,11 +915,11 @@ | ||
| 915 | 915 | repeat |
| 916 | 916 | if t = nil then Expression(e, nil) else Expression(e, t^.base); |
| 917 | 917 | if t = nil then begin |
| 918 | - if e.typ^.form <> fEnum then MarkAt(e.pos, 'a set holds names of an enumeration, found ' + TypeName(e.typ)); | |
| 918 | + if e.typ^.form <> fEnum then MarkAt(e.pos, 'a set holds names of an enumeration, found ' + What(e)); | |
| 919 | 919 | t := SetOf(e.typ, e.pos); |
| 920 | 920 | end; |
| 921 | 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); | |
| 922 | + if e.obj <> nil then s := NameOf(e.obj^.name) else s := What(e); | |
| 923 | 923 | MarkAt(e.pos, s + ' isn''t a name of ' + TypeName(t^.base)); |
| 924 | 924 | end; |
| 925 | 925 | if e.mode = mConst then bits := bits or (int64(1) shl e.val) |
| @@ -405,13 +405,12 @@ | ||
| 405 | 405 | end; |
| 406 | 406 | end; |
| 407 | 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. } | |
| 408 | +{ The text of the file from byte a up to but not including b } | |
| 410 | 409 | function Text(a, b: longint): shortstring; |
| 410 | +var p: TPos; | |
| 411 | 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); | |
| 412 | + p.f := cur.f; p.a := a; p.b := b; | |
| 413 | + Text := Source(p); | |
| 415 | 414 | end; |
| 416 | 415 | |
| 417 | 416 | { One character of a character or string literal, at buf[pos]: its code |
| @@ -1,4 +1,4 @@ | ||
| 1 | -test/err/AtBinary.raz:5:10: error: can't combine I64 and BOOL | |
| 1 | +test/err/AtBinary.raz:5:10: error: I64 and BOOL are different types | |
| 2 | 2 | 5 | x := (x + 2) * b; |
| 3 | 3 | | ^^^^^^^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -1,4 +1,4 @@ | ||
| 1 | -test/err/AtPSetLit.raz:6:14: error: an integer constant isn't a name of C | |
| 1 | +test/err/AtPSetLit.raz:6:14: error: 1 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 types: ^I64 and ^I32 | |
| 1 | +test/err/AtPtrMinus.raz:5:10: error: ^I64 and ^I32 are different types | |
| 2 | 2 | 5 | x := p - q; |
| 3 | 3 | | ^^^^^ |
| 4 | 4 | raz: 1 error |
| @@ -1,4 +1,4 @@ | ||
| 1 | -test/err/DeclIntConst.raz:3:9: error: expected an integer constant, found a real constant | |
| 1 | +test/err/DeclIntConst.raz:3:9: error: expected an integer constant, found 1.5 | |
| 2 | 2 | 3 | var a: [1.5]I64; |
| 3 | 3 | | ^^^ |
| 4 | 4 | raz: 1 error |
| @@ -1,4 +1,4 @@ | ||
| 1 | -test/err/DeclSetNames.raz:6:16: error: a set holds names of an enumeration, found an integer constant | |
| 1 | +test/err/DeclSetNames.raz:6:16: error: a set holds names of an enumeration, found 1 | |
| 2 | 2 | 6 | s := {} + {1}; |
| 3 | 3 | | ^ |
| 4 | 4 | raz: 1 error |
| @@ -1,4 +1,4 @@ | ||
| 1 | -test/err/DeclSyscallArg.raz:5:21: error: expected an integer or a pointer, found a real constant | |
| 1 | +test/err/DeclSyscallArg.raz:5:21: error: expected an integer or a pointer, found 1.5 | |
| 2 | 2 | 5 | n := SYSCALL(1, 1.5); |
| 3 | 3 | | ^^^ |
| 4 | 4 | raz: 1 error |
| @@ -1,4 +1,5 @@ | ||
| 1 | -test/err/GenIntReal.raz:6:10: error: can't combine I64 and F64 | |
| 1 | +test/err/GenIntReal.raz:6:10: error: I64 and F64 are different types | |
| 2 | 2 | 6 | y := x + y; |
| 3 | 3 | | ^^^^^ |
| 4 | +help: convert one to the other's type, as in I64(y) | |
| 4 | 5 | raz: 1 error |
| @@ -1,4 +1,5 @@ | ||
| 1 | -test/err/GenIntTypes.raz:6:10: error: different types: I32 and I64 | |
| 1 | +test/err/GenIntTypes.raz:6:10: error: I32 and I64 are different types | |
| 2 | 2 | 6 | b := a + b; |
| 3 | 3 | | ^^^^^ |
| 4 | +help: convert one to the other's type, as in I32(b) | |
| 4 | 5 | raz: 1 error |
| @@ -1,5 +1,5 @@ | ||
| 1 | -test/err/GenSlash.raz:6:10: error: "/" is for reals, found an integer constant | |
| 1 | +test/err/GenSlash.raz:6:10: error: "/" divides reals, not integers | |
| 2 | 2 | 6 | x := 6 / 3; |
| 3 | 3 | | ^^^^^ |
| 4 | -help: integers divide with "div" | |
| 4 | +help: to divide integers, write 6 div 3 | |
| 5 | 5 | raz: 1 error |
| @@ -1,5 +1,5 @@ | ||
| 1 | -test/err/GenSlashVar.raz:6:10: error: "/" is for reals, found I64 | |
| 1 | +test/err/GenSlashVar.raz:6:10: error: "/" divides reals, not integers | |
| 2 | 2 | 6 | x := x / y; |
| 3 | 3 | | ^^^^^ |
| 4 | -help: integers divide with "div" | |
| 4 | +help: to divide integers, write x div y | |
| 5 | 5 | raz: 1 error |
| @@ -1,4 +1,5 @@ | ||
| 1 | -test/err/Mixed.raz:6:10: error: different types: F32 and F64 | |
| 1 | +test/err/Mixed.raz:6:10: error: F32 and F64 are different types | |
| 2 | 2 | 6 | y := x + y; |
| 3 | 3 | | ^^^^^ |
| 4 | +help: convert one to the other's type, as in F32(y) | |
| 4 | 5 | raz: 1 error |
| @@ -10,13 +10,13 @@ | ||
| 10 | 10 | test/err/Recover.raz:16:10: error: y isn't declared |
| 11 | 11 | 16 | x := y + 1; |
| 12 | 12 | | ^ |
| 13 | -test/err/Recover.raz:19:14: error: can't combine I64 and BOOL | |
| 13 | +test/err/Recover.raz:19:14: error: I64 and BOOL are different types | |
| 14 | 14 | 19 | x := (x + 2) * b; |
| 15 | 15 | | ^^^^^^^^^^^ |
| 16 | 16 | test/err/Recover.raz:20:17: error: z isn't declared |
| 17 | 17 | 20 | Out.int(z); |
| 18 | 18 | | ^ |
| 19 | -test/err/Recover.raz:22:12: error: can't combine I64 and BOOL | |
| 19 | +test/err/Recover.raz:22:12: error: I64 and BOOL are different types | |
| 20 | 20 | 22 | return x + true; |
| 21 | 21 | | ^^^^^^^^ |
| 22 | 22 | test/err/Recover.raz:28:7: error: Q has no field c |