Step 4: the conformance suite, conform/, apart from this compiler's tests conform/run and conform/err: programs whose output, status or rejection the report alone fixes, using only the language and the library no target may leave out. conform/check.sh runs them with any compiler taking -I and -o, and compares its messages only when given a dir of them: test/msg holds this compiler's. Kept in test/: code procs, SYSCALL, extern and link, Thread, target files, warnings and -Werror, the compiler's limits (names in one decl, defers, frame size, ...), record sizes over 64-bit pointers, and the faults caught by signals, whose status the report leaves open. Programs with reals stay in the suite until step 6. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
| @@ -24,11 +24,18 @@ | ||
| 24 | 24 | (`apt-get install -y vim emacs-nox`): each example must indent back |
| 25 | 25 | exactly as written. |
| 26 | 26 | |
| 27 | -`make check` must pass before every commit. Tests: `test/run/X.raz` | |
| 28 | -with `X.expect` (stdout), optional `X.status`, `X.stderr` and | |
| 29 | -`X.args`; modules they import in `test/run/mods`. `test/err/X.raz` | |
| 30 | -must fail to compile with the text in `X.err` (all of standard error), | |
| 31 | -given the compiler options in `X.args` if there is one. | |
| 27 | +`make check` must pass before every commit. The conformance suite, | |
| 28 | +`conform/`, holds what any implementation must do (`conform/check.sh` | |
| 29 | +says how it is laid out); `test/` holds what is this compiler's alone: | |
| 30 | +its messages, its limits, its target. A test goes in `conform/` when | |
| 31 | +the report alone fixes its output and status, and keeps to the | |
| 32 | +language and the library a target can't leave out. Tests: | |
| 33 | +`test/run/X.raz` with `X.expect` (stdout), optional `X.status`, | |
| 34 | +`X.stderr` and `X.args`; modules they import in `test/run/mods`. | |
| 35 | +`test/err/X.raz` must fail to compile with the text in `X.err` (all of | |
| 36 | +standard error), given the compiler options in `X.args` if there is | |
| 37 | +one. `test/msg` holds this compiler's `X.stderr` and `X.err` for the | |
| 38 | +programs in `conform/`. | |
| 32 | 39 | `test/pretty/X.raz` must format to `X.expect`. Examples in `examples/` |
| 33 | 40 | work the same way, compiled with `-Werror`, as are the tools and the |
| 34 | 41 | library's tests: they must have no warnings. |
| @@ -66,7 +66,7 @@ | ||
| 66 | 66 | |
| 67 | 67 | ## Proposed, v0.6.0: raz to be rebuilt by anyone |
| 68 | 68 | |
| 69 | -Under way: steps 1 to 3 are agreed; step 4 is next. The freeze | |
| 69 | +Under way: steps 1 to 3 are agreed; step 4 is for review. The freeze | |
| 70 | 70 | doesn't hold for this work, by the owner's word. |
| 71 | 71 | |
| 72 | 72 | **For:** a language a person alone can implement again, from the |
| @@ -108,7 +108,7 @@ | ||
| 108 | 108 | code close to what the parser asks of `gen` today, with types |
| 109 | 109 | and places, so that a back end turns its stack into registers and |
| 110 | 110 | an interpreter of it stays small. |
| 111 | -- [ ] 4. The tests split: a conformance suite any implementation | |
| 111 | +- [x] 4. The tests split: a conformance suite any implementation | |
| 112 | 112 | passes, apart from this compiler's own messages. |
| 113 | 113 | - [ ] 5. The system integer. |
| 114 | 114 | - [ ] 6. Optional reals: a target says whether it has them. |
| @@ -41,7 +41,8 @@ | ||
| 41 | 41 | | `tools/Doc.raz` | Prints what a module exports, with its comments | |
| 42 | 42 | | `tools/Pretty.raz` | The formatter: fixes indentation and spacing | |
| 43 | 43 | | `editor/` | Support for vim and emacs | |
| 44 | -| `test/` | Tests, and the scripts that run them | | |
| 44 | +| `conform/` | The conformance suite: what every implementation must do | | |
| 45 | +| `test/` | This compiler's own tests, and the scripts that run them | | |
| 45 | 46 | | `PLAN.md` | The plan: the milestone under way and its steps | |
| 46 | 47 | |
| 47 | 48 | ## Building |
| @@ -135,7 +136,7 @@ | ||
| 135 | 136 | $ ./raz -o Doc tools/Doc.raz && ./Doc lib/Str.raz |
| 136 | 137 | |
| 137 | 138 | Each library module's `main` is its test, which `make check` runs; the |
| 138 | -generic ones, which can't run alone, are tested in `test/run`. | |
| 139 | +generic ones, which can't run alone, are tested in `conform/run`. | |
| 139 | 140 | |
| 140 | 141 | ## Editors |
| 141 | 142 |
| @@ -0,0 +1,79 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +# The conformance suite: programs whose behaviour the report defines, | |
| 3 | +# which every implementation of raz must give, whatever its target. | |
| 4 | +# | |
| 5 | +# conform/check.sh COMPILER [MESSAGES] | |
| 6 | +# | |
| 7 | +# run from the directory above conform/. COMPILER is run as | |
| 8 | +# COMPILER -I DIR -o EXE FILE | |
| 9 | +# to compile FILE, finding the modules it imports, besides the | |
| 10 | +# library's, in DIR, into the executable EXE; an implementation run | |
| 11 | +# otherwise is given a script that runs it so. | |
| 12 | +# | |
| 13 | +# run/X.raz a program; run/mods holds the modules it imports | |
| 14 | +# run/X.expect its standard output | |
| 15 | +# run/X.args its arguments, one per line (optional) | |
| 16 | +# run/X.status its exit status (optional; 0 if missing) | |
| 17 | +# err/X.raz a program the report says is an error, which must not | |
| 18 | +# compile; err/mods holds the modules it imports | |
| 19 | +# | |
| 20 | +# What a program says on standard error, the compiler's messages | |
| 21 | +# included, is the implementation's own (appendix A). One that keeps | |
| 22 | +# its text may give MESSAGES, a directory of X.stderr and X.err, the | |
| 23 | +# standard error of run/X and of compiling err/X, compared when there. | |
| 24 | +# | |
| 25 | +# Programs that use reals are among the rest, until a target may leave | |
| 26 | +# them out. | |
| 27 | + | |
| 28 | +raz=$1 | |
| 29 | +msg=${2:-/nonexistent} | |
| 30 | +out=build/conform | |
| 31 | +mkdir -p $out | |
| 32 | +pass=0 | |
| 33 | +fail=0 | |
| 34 | + | |
| 35 | +for f in conform/run/*.raz; do | |
| 36 | + name=$(basename $f .raz) | |
| 37 | + if ! $raz -I conform/run/mods -o $out/$name $f 2>$out/$name.cerr; then | |
| 38 | + echo "FAIL $f: doesn't compile: $(cat $out/$name.cerr)" | |
| 39 | + fail=$((fail + 1)); continue | |
| 40 | + fi | |
| 41 | + set -- | |
| 42 | + if [ -f conform/run/$name.args ]; then | |
| 43 | + while IFS= read -r a; do set -- "$@" "$a"; done < conform/run/$name.args | |
| 44 | + fi | |
| 45 | + # in $(...), so that what the shell says of a signal goes nowhere | |
| 46 | + status=$( { ( exec $out/$name "$@" ) > $out/$name.out 2>$out/$name.err; echo $?; } 2>/dev/null ) | |
| 47 | + want=0 | |
| 48 | + [ -f conform/run/$name.status ] && want=$(cat conform/run/$name.status) | |
| 49 | + if ! cmp -s $out/$name.out conform/run/$name.expect; then | |
| 50 | + echo "FAIL $f: output differs" | |
| 51 | + diff $out/$name.out conform/run/$name.expect | head -5 | |
| 52 | + fail=$((fail + 1)) | |
| 53 | + elif [ $status != $want ]; then | |
| 54 | + echo "FAIL $f: status $status, not $want" | |
| 55 | + fail=$((fail + 1)) | |
| 56 | + elif [ -f $msg/$name.stderr ] && ! cmp -s $out/$name.err $msg/$name.stderr; then | |
| 57 | + echo "FAIL $f: standard error differs" | |
| 58 | + diff $out/$name.err $msg/$name.stderr | head -5 | |
| 59 | + fail=$((fail + 1)) | |
| 60 | + else | |
| 61 | + pass=$((pass + 1)) | |
| 62 | + fi | |
| 63 | +done | |
| 64 | + | |
| 65 | +for f in conform/err/*.raz; do | |
| 66 | + name=$(basename $f .raz) | |
| 67 | + if $raz -I conform/err/mods -o $out/$name $f 2>$out/$name.cerr; then | |
| 68 | + echo "FAIL $f: compiles" | |
| 69 | + fail=$((fail + 1)) | |
| 70 | + elif [ -f $msg/$name.err ] && ! cmp -s $msg/$name.err $out/$name.cerr; then | |
| 71 | + echo "FAIL $f: says"; diff $msg/$name.err $out/$name.cerr | |
| 72 | + fail=$((fail + 1)) | |
| 73 | + else | |
| 74 | + pass=$((pass + 1)) | |
| 75 | + fi | |
| 76 | +done | |
| 77 | + | |
| 78 | +echo "$pass passed, $fail failed" | |
| 79 | +[ $fail = 0 ] |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AmpBools; | |
| 2 | +proc main*; | |
| 3 | +var b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + b := b & true; | |
| 6 | +end; | |
| 7 | +end AmpBools. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module ArrayEqReal; | |
| 2 | + | |
| 3 | +proc main*; | |
| 4 | +var a, b: [2]F64; | |
| 5 | +begin | |
| 6 | + if a = b then end; | |
| 7 | +end; | |
| 8 | + | |
| 9 | +end ArrayEqReal. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module ArrayEqRecord; | |
| 2 | + | |
| 3 | +proc main*; | |
| 4 | +var a, b: [2]record x: I64; end; | |
| 5 | +begin | |
| 6 | + if a = b then end; | |
| 7 | +end; | |
| 8 | + | |
| 9 | +end ArrayEqRecord. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module ArrayEqTypes; | |
| 2 | + | |
| 3 | +proc main*; | |
| 4 | +var a: [2]I64; b: [2]I32; | |
| 5 | +begin | |
| 6 | + if a # b then end; | |
| 7 | +end; | |
| 8 | + | |
| 9 | +end ArrayEqTypes. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module Assign; | |
| 2 | +proc main*; | |
| 3 | +var a: I64; b: I32; | |
| 4 | +begin | |
| 5 | + a := b; | |
| 6 | +end; | |
| 7 | +end Assign. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtAnd; | |
| 2 | +proc main*; | |
| 3 | +var b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + b := b and (x + 1); | |
| 6 | +end; | |
| 7 | +end AtAnd. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module AtArgType; | |
| 2 | +proc Id(a: I64): I64; | |
| 3 | +begin return a; end; | |
| 4 | +proc main*; | |
| 5 | +var b: BOOL; | |
| 6 | +begin | |
| 7 | + Id(b); | |
| 8 | +end; | |
| 9 | +end AtArgType. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtBinary; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; b: BOOL; | |
| 4 | +begin | |
| 5 | + x := (x + 2) * b; | |
| 6 | +end; | |
| 7 | +end AtBinary. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtCall; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; | |
| 4 | +begin | |
| 5 | + x := x(1); | |
| 6 | +end; | |
| 7 | +end AtCall. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtCondition; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; | |
| 4 | +begin | |
| 5 | + if x + 1 then end; | |
| 6 | +end; | |
| 7 | +end AtCondition. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtConstFit; | |
| 2 | +proc main*; | |
| 3 | +var x: I32; | |
| 4 | +begin | |
| 5 | + x := 5 + 3000000000; | |
| 6 | +end; | |
| 7 | +end AtConstFit. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtConvert; | |
| 2 | +proc main*; | |
| 3 | +var b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + x := I64(b); | |
| 6 | +end; | |
| 7 | +end AtConvert. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtDeref; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + y := x^; | |
| 6 | +end; | |
| 7 | +end AtDeref. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtDivZero; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; | |
| 4 | +begin | |
| 5 | + x := 7 div (3 - 3); | |
| 6 | +end; | |
| 7 | +end AtDivZero. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtIndex; | |
| 2 | +proc main*; | |
| 3 | +var a: [4]I64; b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + x := a[b]; | |
| 6 | +end; | |
| 7 | +end AtIndex. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module AtMany; | |
| 2 | +proc Id(a: I64): I64; | |
| 3 | +begin return a; end; | |
| 4 | +proc main*; | |
| 5 | +var x: I64; | |
| 6 | +begin | |
| 7 | + x := Id(1, 2 * 3); | |
| 8 | +end; | |
| 9 | +end AtMany. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtMatch; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; | |
| 4 | +begin | |
| 5 | + match x + 1 do end; | |
| 6 | +end; | |
| 7 | +end AtMatch. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtNegate; | |
| 2 | +proc main*; | |
| 3 | +var b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + x := -b; | |
| 6 | +end; | |
| 7 | +end AtNegate. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtNot; | |
| 2 | +proc main*; | |
| 3 | +var s: []U8; b: BOOL; | |
| 4 | +begin | |
| 5 | + b := not s; | |
| 6 | +end; | |
| 7 | +end AtNot. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtNotValue; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; | |
| 4 | +begin | |
| 5 | + x := I64 + 1; | |
| 6 | +end; | |
| 7 | +end AtNotValue. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPAdr; | |
| 2 | +proc main*; | |
| 3 | +var p: ^I64; | |
| 4 | +begin | |
| 5 | + p := ADR(1); | |
| 6 | +end; | |
| 7 | +end AtPAdr. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module AtPArrayLen; | |
| 2 | +var a: [0]I64; | |
| 3 | +proc main*; | |
| 4 | +begin | |
| 5 | +end; | |
| 6 | +end AtPArrayLen. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module AtPCantAssign; | |
| 2 | +const k = 1; | |
| 3 | +proc two: (I64, I64); begin return 1, 2; end; | |
| 4 | +proc main*; | |
| 5 | +var a: I64; | |
| 6 | +begin | |
| 7 | + a, k := two(); | |
| 8 | +end; | |
| 9 | +end AtPCantAssign. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPChar; | |
| 2 | +proc main*; | |
| 3 | +var a: I64; | |
| 4 | +begin | |
| 5 | + a := 1 ? 2; | |
| 6 | +end; | |
| 7 | +end AtPChar. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module AtPComment; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | +end; | |
| 5 | +(* never closed | |
| 6 | +end AtPComment. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPConstExpr; | |
| 2 | +proc main*; | |
| 3 | +var n: I64; | |
| 4 | +var a: [n]I64; | |
| 5 | +begin | |
| 6 | +end; | |
| 7 | +end AtPConstExpr. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPElems; | |
| 2 | +proc main*; | |
| 3 | +var a: [3]I64; | |
| 4 | +begin | |
| 5 | + a := [1, 2]; | |
| 6 | +end; | |
| 7 | +end AtPElems. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPEscape; | |
| 2 | +proc main*; | |
| 3 | +var s: [8]U8; | |
| 4 | +begin | |
| 5 | + s := "a\q"; | |
| 6 | +end; | |
| 7 | +end AtPEscape. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPInc; | |
| 2 | +proc main*; | |
| 3 | +var a: BOOL; | |
| 4 | +begin | |
| 5 | + INC(a); | |
| 6 | +end; | |
| 7 | +end AtPInc. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPLen; | |
| 2 | +proc main*; | |
| 3 | +var a: I64; | |
| 4 | +begin | |
| 5 | + a := LEN(a); | |
| 6 | +end; | |
| 7 | +end AtPLen. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPNewVar; | |
| 2 | +proc main*; | |
| 3 | +var a: I64; | |
| 4 | +begin | |
| 5 | + NEW(a, a); | |
| 6 | +end; | |
| 7 | +end AtPNewVar. |
| @@ -0,0 +1,10 @@ | ||
| 1 | +module AtPNoResult; | |
| 2 | +proc p; | |
| 3 | +begin | |
| 4 | +end; | |
| 5 | +proc main*; | |
| 6 | +var a: I64; | |
| 7 | +begin | |
| 8 | + a := p() + 1; | |
| 9 | +end; | |
| 10 | +end AtPNoResult. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPNotRecord; | |
| 2 | +proc main*; | |
| 3 | +var a: I64; | |
| 4 | +begin | |
| 5 | + a := a.f; | |
| 6 | +end; | |
| 7 | +end AtPNotRecord. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPNotStmt; | |
| 2 | +proc main*; | |
| 3 | +var a: I64; | |
| 4 | +begin | |
| 5 | + a; | |
| 6 | +end; | |
| 7 | +end AtPNotStmt. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module AtPSetLit; | |
| 2 | +type C = (r, g, b); | |
| 3 | +proc main*; | |
| 4 | +var s: set of C; | |
| 5 | +begin | |
| 6 | + s := {r, 1}; | |
| 7 | +end; | |
| 8 | +end AtPSetLit. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPStep; | |
| 2 | +proc main*; | |
| 3 | +var i: I64; | |
| 4 | +begin | |
| 5 | + for i := 1 to 5 by 1 - 1 do end; | |
| 6 | +end; | |
| 7 | +end AtPStep. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtPtrMinus; | |
| 2 | +proc main*; | |
| 3 | +var p: ^I64; q: ^I32; x: I64; | |
| 4 | +begin | |
| 5 | + x := p - q; | |
| 6 | +end; | |
| 7 | +end AtPtrMinus. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module AtReturn; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + return 1 + 2; | |
| 5 | +end; | |
| 6 | +end AtReturn. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtSliceHi; | |
| 2 | +proc main*; | |
| 3 | +var a: [4]I64; b: BOOL; s: []I64; | |
| 4 | +begin | |
| 5 | + s := a[0..b]; | |
| 6 | +end; | |
| 7 | +end AtSliceHi. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtSliceLo; | |
| 2 | +proc main*; | |
| 3 | +var a: [4]I64; b: BOOL; s: []I64; | |
| 4 | +begin | |
| 5 | + s := a[b..2]; | |
| 6 | +end; | |
| 7 | +end AtSliceLo. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module AtStrCmp; | |
| 2 | +proc main*; | |
| 3 | +var s: []U8; x: I64; | |
| 4 | +begin | |
| 5 | + if s = x + 1 then end; | |
| 6 | +end; | |
| 7 | +end AtStrCmp. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module AtVarArg; | |
| 2 | +proc Inc(var a: I64); | |
| 3 | +begin a := a + 1; end; | |
| 4 | +proc main*; | |
| 5 | +var x: I64; | |
| 6 | +begin | |
| 7 | + Inc(1 + 2); | |
| 8 | +end; | |
| 9 | +end AtVarArg. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module BadProc; | |
| 2 | +import Str, M := Map([]U8, I64, Str.cmp, Str.eq); | |
| 3 | + | |
| 4 | +var m: M.Map; | |
| 5 | + | |
| 6 | +end BadProc. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module BarBools; | |
| 2 | +proc main*; | |
| 3 | +var b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + b := b | true; | |
| 6 | +end; | |
| 7 | +end BarBools. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module BigI64; | |
| 2 | +proc main*; | |
| 3 | +var i: I64; | |
| 4 | +begin | |
| 5 | + i := 0FFFFFFFFFFFFFFFFH; | |
| 6 | +end; | |
| 7 | +end BigI64. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module Break; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + break; | |
| 5 | +end; | |
| 6 | +end Break. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module Cycle; | |
| 2 | +import CycleB; | |
| 3 | +end Cycle. |
| @@ -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,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,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,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,6 @@ | ||
| 1 | +module DeclIntConst; | |
| 2 | +proc main*; | |
| 3 | +var a: [1.5]I64; | |
| 4 | +begin | |
| 5 | +end; | |
| 6 | +end DeclIntConst. |
| @@ -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,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,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,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,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,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,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,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,6 @@ | ||
| 1 | +module DeclSetType; | |
| 2 | +proc main*; | |
| 3 | +var s: set of I64; | |
| 4 | +begin | |
| 5 | +end; | |
| 6 | +end DeclSetType. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module DeclSetUnknown; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + if {} = {} then end; | |
| 5 | +end; | |
| 6 | +end DeclSetUnknown. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module DeferBreak; | |
| 2 | +proc f; | |
| 3 | +begin | |
| 4 | + while true do | |
| 5 | + defer break; | |
| 6 | + end; | |
| 7 | +end; | |
| 8 | +end DeferBreak. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module DeferDefer; | |
| 2 | +proc f; | |
| 3 | +begin | |
| 4 | + defer defer f; | |
| 5 | +end; | |
| 6 | +end DeferDefer. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module DeferReturn; | |
| 2 | +proc f: I64; | |
| 3 | +begin | |
| 4 | + defer return 1; | |
| 5 | + return 0; | |
| 6 | +end; | |
| 7 | +end DeferReturn. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ErrOrder; | |
| 2 | +const A: ERROR = "a"; B: ERROR = "b"; | |
| 3 | +proc main*; | |
| 4 | +begin | |
| 5 | + if A < B then end; | |
| 6 | +end; | |
| 7 | +end ErrOrder. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module FirstUseLate; | |
| 2 | +import L := List(Later); | |
| 3 | + | |
| 4 | +var l: L.List; (* made here, before Later is declared *) | |
| 5 | + | |
| 6 | +type Later = I64; | |
| 7 | + | |
| 8 | +end FirstUseLate. |
| @@ -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,14 @@ | ||
| 1 | +module GenConstOverflow; | |
| 2 | +(* An untyped constant doesn't wrap *) | |
| 3 | +const | |
| 4 | + Big = 9223372036854775807; | |
| 5 | + Over = Big + 1; | |
| 6 | + Twice = 4611686018427387904 * 2; | |
| 7 | + Under = -Big - 2; | |
| 8 | + Fine = U8(250) + 10; | |
| 9 | + | |
| 10 | +proc main*; | |
| 11 | +begin | |
| 12 | +end; | |
| 13 | + | |
| 14 | +end GenConstOverflow. |
| @@ -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,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,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,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,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,7 @@ | ||
| 1 | +module GenErrorString; | |
| 2 | +const E: ERROR = 1; | |
| 3 | +proc main*; | |
| 4 | +begin | |
| 5 | + | |
| 6 | +end; | |
| 7 | +end GenErrorString. |
| @@ -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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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. |
| @@ -0,0 +1,11 @@ | ||
| 1 | +module Match; | |
| 2 | +type S = variant a; b; c; end; | |
| 3 | +proc main*; | |
| 4 | +var s: S; | |
| 5 | +begin | |
| 6 | + match s of | |
| 7 | + | a: s := b; | |
| 8 | + | b: | |
| 9 | + end; | |
| 10 | +end; | |
| 11 | +end Match. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module Mixed; | |
| 2 | + | |
| 3 | +proc main*; | |
| 4 | +var x: F32; y: F64; | |
| 5 | +begin | |
| 6 | + y := x + y; | |
| 7 | +end; | |
| 8 | + | |
| 9 | +end Mixed. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module NegU64; | |
| 2 | +proc main*; | |
| 3 | +var u: U64; | |
| 4 | +begin | |
| 5 | + u := -1; | |
| 6 | +end; | |
| 7 | +end NegU64. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module NoArgs; | |
| 2 | +import List; | |
| 3 | +end NoArgs. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module NotGeneric; | |
| 2 | +import S := Str(I64); | |
| 3 | + | |
| 4 | +proc f(a, b: []U8): I64; | |
| 5 | +begin | |
| 6 | + return S.cmp(a, b); | |
| 7 | +end; | |
| 8 | + | |
| 9 | +end NotGeneric. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module NotInt; | |
| 2 | +proc main*; | |
| 3 | +var b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + x := not x; | |
| 6 | +end; | |
| 7 | +end NotInt. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module NoteBuiltin; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + x := len(y); | |
| 6 | +end; | |
| 7 | +end NoteBuiltin. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module NoteExport; | |
| 2 | +import Out; | |
| 3 | +proc main*; | |
| 4 | +var x, y: I64; | |
| 5 | +begin | |
| 6 | + Out.Int(x); | |
| 7 | +end; | |
| 8 | +end NoteExport. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module NoteField; | |
| 2 | +type P = record count: I64; end; | |
| 3 | +proc main*; | |
| 4 | +var p: P; | |
| 5 | +begin | |
| 6 | + p.cuont := 1; | |
| 7 | +end; | |
| 8 | +end NoteField. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module NoteImport; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + Fmt.print(x); | |
| 6 | +end; | |
| 7 | +end NoteImport. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module NoteLocal; | |
| 2 | +proc main*; | |
| 3 | +var x, y, count: I64; | |
| 4 | +begin | |
| 5 | + | |
| 6 | + cuont := 1; | |
| 7 | +end; | |
| 8 | +end NoteLocal. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module OrInts; | |
| 2 | +proc main*; | |
| 3 | +var b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + x := x or 1; | |
| 6 | +end; | |
| 7 | +end OrInts. |
| @@ -0,0 +1,24 @@ | ||
| 1 | +module PackedAddress; | |
| 2 | +(* A field of a packed record may be misaligned: it has no address, | |
| 3 | + and no volatile access *) | |
| 4 | +type | |
| 5 | + Header = packed record kind: U8; len: U32; tag: U8; vals: [2]U16; end; | |
| 6 | + | |
| 7 | +proc put(var n: U32); | |
| 8 | +begin | |
| 9 | + n := 1; | |
| 10 | +end; | |
| 11 | + | |
| 12 | +proc main*; | |
| 13 | +var h: Header; p: ^U32; q: ^VOLATILE Header; k: ^U8; s: []U16; | |
| 14 | +begin | |
| 15 | + p := ADR(h.len); | |
| 16 | + put(h.len); | |
| 17 | + s := h.vals[0..1]; | |
| 18 | + q := ADR(h); | |
| 19 | + q^.len := 2; | |
| 20 | + k := ADR(h.tag); | |
| 21 | + h.len := 3; | |
| 22 | +end; | |
| 23 | + | |
| 24 | +end PackedAddress. |
| @@ -0,0 +1,19 @@ | ||
| 1 | +module PassOnTypes; | |
| 2 | + | |
| 3 | +proc two(n: I64): (I64, BOOL); | |
| 4 | +begin | |
| 5 | + return n, n = 0; | |
| 6 | +end; | |
| 7 | + | |
| 8 | +proc swapped(n: I64): (BOOL, I64); | |
| 9 | +begin | |
| 10 | + return two(n); | |
| 11 | +end; | |
| 12 | + | |
| 13 | +proc main*; | |
| 14 | +var b: BOOL; i: I64; | |
| 15 | +begin | |
| 16 | + b, i := swapped(1); | |
| 17 | +end; | |
| 18 | + | |
| 19 | +end PassOnTypes. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module PtrArray; | |
| 2 | +proc main*; | |
| 3 | +var a: [4]I64; p: ^[4]I64; | |
| 4 | +begin | |
| 5 | + p := ADR(a); | |
| 6 | + p[1] := 0; | |
| 7 | +end; | |
| 8 | +end PtrArray. |
| @@ -0,0 +1,40 @@ | ||
| 1 | +module Recover; | |
| 2 | + | |
| 3 | +import Out; | |
| 4 | + | |
| 5 | +type | |
| 6 | + P = record a: I64; b: Foo; end; | |
| 7 | + Q = record a: I64; end; | |
| 8 | + | |
| 9 | +var g: Bar; | |
| 10 | + h: I64; | |
| 11 | + | |
| 12 | +proc f(x: I64): I64; | |
| 13 | +var b: BOOL; | |
| 14 | +begin | |
| 15 | + b := x; | |
| 16 | + x := y + 1; | |
| 17 | + x := y * 2; | |
| 18 | + if x = 1 then | |
| 19 | + x := (x + 2) * b; | |
| 20 | + Out.int(z); | |
| 21 | + end; | |
| 22 | + return x + true; | |
| 23 | +end f; | |
| 24 | + | |
| 25 | +proc g2(): Q; | |
| 26 | +var q: Q; | |
| 27 | +begin | |
| 28 | + q.c := 1; | |
| 29 | + h := g; | |
| 30 | + Out.str("hi") | |
| 31 | + return q; | |
| 32 | +end g2; | |
| 33 | + | |
| 34 | +proc main*(); | |
| 35 | +begin | |
| 36 | + Out.int(f(1)); | |
| 37 | + Out.int(nope(2)); | |
| 38 | +end main; | |
| 39 | + | |
| 40 | +end Recover. |
| @@ -0,0 +1,35 @@ | ||
| 1 | +module Resync; | |
| 2 | + | |
| 3 | +import Out; | |
| 4 | + | |
| 5 | +proc a(x: I64); | |
| 6 | +begin | |
| 7 | + if x = 1 then | |
| 8 | + x := 2; | |
| 9 | + Out.int(x); | |
| 10 | +end a; | |
| 11 | + | |
| 12 | +proc b(x: I64); | |
| 13 | +begin | |
| 14 | + while x > 0 do x := x - 1 end; | |
| 15 | + x := ) + 2; | |
| 16 | + match x | |
| 17 | + | 1: x := true; | |
| 18 | + end; | |
| 19 | +end b; | |
| 20 | + | |
| 21 | +proc c(x: I64); | |
| 22 | +begin | |
| 23 | + x := 1 +; | |
| 24 | + | |
| 25 | +proc d(x: I64); | |
| 26 | +begin | |
| 27 | + x := false; | |
| 28 | +end d; | |
| 29 | + | |
| 30 | +proc main*(); | |
| 31 | +begin | |
| 32 | + a(1); b(2); c(3); d(4); | |
| 33 | +end main; | |
| 34 | + | |
| 35 | +end Resync. |
| @@ -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,7 @@ | ||
| 1 | +module ScanBigHex; | |
| 2 | +proc main*; | |
| 3 | +var x: U64; | |
| 4 | +begin | |
| 5 | + x := 10000000000000000H; | |
| 6 | +end; | |
| 7 | +end ScanBigHex. |
| @@ -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,7 @@ | ||
| 1 | +module ScanCharOpen; | |
| 2 | +proc main*; | |
| 3 | +var c: U8; | |
| 4 | +begin | |
| 5 | + c := 'ab'; | |
| 6 | +end; | |
| 7 | +end ScanCharOpen. |
| @@ -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,6 @@ | ||
| 1 | +module ScanComment; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + (* never closed | |
| 5 | +end; | |
| 6 | +end ScanComment. |
| @@ -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,7 @@ | ||
| 1 | +module ScanHexChar; | |
| 2 | +proc main*; | |
| 3 | +var c: U8; | |
| 4 | +begin | |
| 5 | + c := '\x41'; | |
| 6 | +end; | |
| 7 | +end ScanHexChar. |
| @@ -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,7 @@ | ||
| 1 | +module ScanHexH; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; | |
| 4 | +begin | |
| 5 | + x := 12A; | |
| 6 | +end; | |
| 7 | +end ScanHexH. |
| @@ -0,0 +1,5 @@ | ||
| 1 | +module ScanMain; | |
| 2 | +proc main*(_n: I64); | |
| 3 | +begin | |
| 4 | +end; | |
| 5 | +end ScanMain. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module ScanName; | |
| 2 | +proc main*; | |
| 3 | +begin | |
| 4 | + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; | |
| 5 | +end; | |
| 6 | +end ScanName. |
| @@ -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.
| @@ -0,0 +1,7 @@ | ||
| 1 | +module ScanRealBig; | |
| 2 | +proc main*; | |
| 3 | +var x: F64; | |
| 4 | +begin | |
| 5 | + x := 1.8E308; | |
| 6 | +end; | |
| 7 | +end ScanRealBig. |
| @@ -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,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,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,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,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,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,7 @@ | ||
| 1 | +module ScanUtf8; | |
| 2 | +proc main*; | |
| 3 | +var s: [4]U8; | |
| 4 | +begin | |
| 5 | + s := "ÿ"; | |
| 6 | +end; | |
| 7 | +end ScanUtf8. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipAnd; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + if (x = 1) && (y = 2) then x := 2; end; | |
| 6 | +end; | |
| 7 | +end SlipAnd. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipAssign; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + x = 1; | |
| 6 | +end; | |
| 7 | +end SlipAssign. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipBrace; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + if x = 1 { x := 2 } | |
| 6 | +end; | |
| 7 | +end SlipBrace. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipDo; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + while x < 3 { x := x + 1 } | |
| 6 | +end; | |
| 7 | +end SlipDo. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipElif; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + if x = 1 then x := 2; elif x = 3 then x := 4; end; | |
| 6 | +end; | |
| 7 | +end SlipElif. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipEql; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + if x == 1 then x := 2; end; | |
| 6 | +end; | |
| 7 | +end SlipEql. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipMany; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + if x != 1 && z then x := y; end; | |
| 6 | +end; | |
| 7 | +end SlipMany. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipNeq; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + if x != 1 then x := 2; end; | |
| 6 | +end; | |
| 7 | +end SlipNeq. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipNot; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + if ! (x = 1) then x := 2; end; | |
| 6 | +end; | |
| 7 | +end SlipNot. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module SlipOr; | |
| 2 | +proc main*; | |
| 3 | +var x, y: I64; | |
| 4 | +begin | |
| 5 | + if (x = 1) || (y = 2) then x := 2; end; | |
| 6 | +end; | |
| 7 | +end SlipOr. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module StmtArgKind; | |
| 2 | +import Mem, L := List(Mem.Page); | |
| 3 | + | |
| 4 | +var l: L.List; | |
| 5 | + | |
| 6 | +end StmtArgKind. |
| @@ -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,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,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,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,2 @@ | ||
| 1 | +module StmtDot; | |
| 2 | +end StmtDot; |
| @@ -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,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,2 @@ | ||
| 1 | +module StmtEndName; | |
| 2 | +end Other. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtErrType; | |
| 2 | +const k: I64 = "a"; | |
| 3 | +end StmtErrType. |
| @@ -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,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,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,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,4 @@ | ||
| 1 | +module StmtForwardTwice; | |
| 2 | +proc f; forward; | |
| 3 | +proc f; forward; | |
| 4 | +end StmtForwardTwice. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtFwdPtr; | |
| 2 | +type P = ^Missing; | |
| 3 | +end StmtFwdPtr. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtImportName; | |
| 2 | +import 5; | |
| 3 | +end StmtImportName. |
| @@ -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,6 @@ | ||
| 1 | +module StmtManyTypeArgs; | |
| 2 | +import L := List(I64, I64); | |
| 3 | + | |
| 4 | +var l: L.List; | |
| 5 | + | |
| 6 | +end StmtManyTypeArgs. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module StmtNeedProc; | |
| 2 | +import Str, M := Map([]U8, I64, I64, Str.eq); | |
| 3 | + | |
| 4 | +var m: M.Map; | |
| 5 | + | |
| 6 | +end StmtNeedProc. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module StmtNeedType; | |
| 2 | +import Str, M := Map(Str.cmp, I64, Str.cmp, Str.eq); | |
| 3 | + | |
| 4 | +var m: M.Map; | |
| 5 | + | |
| 6 | +end StmtNeedType. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +module StmtNest; | |
| 2 | +proc main*; | |
| 3 | + proc inner; forward; | |
| 4 | +begin | |
| 5 | +end; | |
| 6 | +end StmtNest. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtNeverDefined; | |
| 2 | +proc f; forward; | |
| 3 | +end StmtNeverDefined. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtNoModule; | |
| 2 | +import Nothing; | |
| 3 | +end StmtNoModule. |
| @@ -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,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,6 @@ | ||
| 1 | +module StmtParamName; | |
| 2 | +import L := StmtParam(I64); | |
| 3 | + | |
| 4 | +var l: L.T; | |
| 5 | + | |
| 6 | +end StmtParamName. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtProcName; | |
| 2 | +proc main*; begin end mian; | |
| 3 | +end StmtProcName. |
| @@ -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,4 @@ | ||
| 1 | +module StmtSigForward; | |
| 2 | +proc f(a: I64); forward; | |
| 3 | +proc f(a: BOOL); begin end; | |
| 4 | +end StmtSigForward. |
| @@ -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,3 @@ | ||
| 1 | +module StmtVarOrProc; | |
| 2 | +extern 5; | |
| 3 | +end StmtVarOrProc. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module StmtWrongModule; | |
| 2 | +import StmtOther; | |
| 3 | +end StmtWrongModule. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module TildeBool; | |
| 2 | +proc main*; | |
| 3 | +var b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + b := ~b; | |
| 6 | +end; | |
| 7 | +end TildeBool. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module Tuple; | |
| 2 | +proc two: (I64, I64); begin return 1, 2; end; | |
| 3 | +proc main*; | |
| 4 | +var a: I64; | |
| 5 | +begin | |
| 6 | + a := two() + 1; | |
| 7 | +end; | |
| 8 | +end Tuple. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module TwoTypes; | |
| 2 | +import A := List(I64), B := List(I32); | |
| 3 | +proc main*; | |
| 4 | +var a: A.List; b: B.List; | |
| 5 | +begin | |
| 6 | + a := b; | |
| 7 | +end; | |
| 8 | +end TwoTypes. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module Utf; | |
| 2 | +var é: I64; | |
| 3 | +end Utf. |
| @@ -0,0 +1,8 @@ | ||
| 1 | +module Volatile; | |
| 2 | +proc main*; | |
| 3 | +var x: I64; p: ^VOLATILE I64; q: ^I64; | |
| 4 | +begin | |
| 5 | + p := ADR(x); | |
| 6 | + q := p; | |
| 7 | +end; | |
| 8 | +end Volatile. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module XorBools; | |
| 2 | +proc main*; | |
| 3 | +var b: BOOL; x: I64; | |
| 4 | +begin | |
| 5 | + b := b xor true; | |
| 6 | +end; | |
| 7 | +end XorBools. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module Cycle; | |
| 2 | +import CycleB; | |
| 3 | +end Cycle. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +module CycleB; | |
| 2 | +import Cycle; | |
| 3 | +end CycleB. |
| @@ -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. |
| @@ -0,0 +1,5 @@ | ||
| 1 | +1001000 | |
| 2 | +1001000 | |
| 3 | +7 | |
| 4 | +10100 | |
| 5 | +nil again 0 |
| @@ -0,0 +1,66 @@ | ||
| 1 | +module Alloc; | |
| 2 | +import Out, Mem, Arena, Heap; | |
| 3 | + | |
| 4 | +type | |
| 5 | + Node = record next: ^Node; val: I64; pad: [5]I64; end; | |
| 6 | + Big = record data: [1000]I64; end; | |
| 7 | + | |
| 8 | +proc build(a: ^Mem.Allocator; n: I64): ^Node; | |
| 9 | +var head, p: ^Node; i: I64; | |
| 10 | +begin | |
| 11 | + head := nil; | |
| 12 | + for i := 1 to n do | |
| 13 | + NEW(p, a); | |
| 14 | + if p = nil then return nil; end; | |
| 15 | + if p^.val # 0 then Out.str("not zeroed "); end; | |
| 16 | + p^.val := i; | |
| 17 | + p^.pad[4] := i; | |
| 18 | + p^.next := head; | |
| 19 | + head := p; | |
| 20 | + end; | |
| 21 | + return head; | |
| 22 | +end; | |
| 23 | + | |
| 24 | +proc sum(p: ^Node): I64; | |
| 25 | +var s: I64; | |
| 26 | +begin | |
| 27 | + s := 0; | |
| 28 | + while p # nil do s := s + p^.val + p^.pad[4]; p := p^.next; end; | |
| 29 | + return s; | |
| 30 | +end; | |
| 31 | + | |
| 32 | +proc release(a: ^Mem.Allocator; p: ^Node); | |
| 33 | +var next: ^Node; | |
| 34 | +begin | |
| 35 | + while p # nil do | |
| 36 | + next := p^.next; | |
| 37 | + Mem.free(a, ^U8(p)); | |
| 38 | + p := next; | |
| 39 | + end; | |
| 40 | +end; | |
| 41 | + | |
| 42 | +proc main*; | |
| 43 | +var ar: Arena.Arena; l, m: ^Node; b: ^Big; i: I64; small: ^U8; again: ^Node; | |
| 44 | +begin | |
| 45 | + l := build(Heap.heap, 1000); | |
| 46 | + Out.int(sum(l)); Out.ln; | |
| 47 | + release(Heap.heap, l); | |
| 48 | + m := build(Heap.heap, 1000); | |
| 49 | + Out.int(sum(m)); Out.ln; | |
| 50 | + NEW(b, Heap.heap); | |
| 51 | + b^.data[999] := 7; | |
| 52 | + Out.int(b^.data[999] + b^.data[0]); Out.ln; | |
| 53 | + Mem.free(Heap.heap, ^U8(b)); | |
| 54 | + if not Arena.init(ADR(ar), 8192) then Out.str("no arena"); end; | |
| 55 | + l := build(ADR(ar.base), 100); | |
| 56 | + Out.int(sum(l)); Out.ln; | |
| 57 | + l := build(ADR(ar.base), 1000); | |
| 58 | + if l = nil then Out.str("nil "); end; | |
| 59 | + Arena.reset(ADR(ar)); | |
| 60 | + NEW(again, ADR(ar.base)); | |
| 61 | + if again # nil then Out.str("again "); Out.int(again^.val); end; | |
| 62 | + Out.ln; | |
| 63 | + Arena.done(ADR(ar)); | |
| 64 | +end; | |
| 65 | + | |
| 66 | +end Alloc. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +one | |
| 2 | +two words | |
| 3 | +é |
| @@ -0,0 +1,3 @@ | ||
| 1 | +one | |
| 2 | +two words | |
| 3 | +é |
| @@ -0,0 +1,18 @@ | ||
| 1 | +module Args; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +proc main*: I64; | |
| 5 | +var i, n: I64; a: ^^U8; s: ^U8; | |
| 6 | +begin | |
| 7 | + a := ARGV(); | |
| 8 | + for i := 1 to ARGC() - 1 do | |
| 9 | + s := a[i]; | |
| 10 | + n := 0; | |
| 11 | + while s[n] # 0 do n := n + 1; end; | |
| 12 | + Out.str(s[0..n]); | |
| 13 | + Out.ln; | |
| 14 | + end; | |
| 15 | + return ARGC(); | |
| 16 | +end; | |
| 17 | + | |
| 18 | +end Args. |
| @@ -0,0 +1 @@ | ||
| 1 | +4 |
| @@ -0,0 +1,35 @@ | ||
| 1 | +M 32 | |
| 2 | +add 22 | |
| 3 | +sub 12 | |
| 4 | +mul 85 | |
| 5 | +div -3 | |
| 6 | +mod -1 | |
| 7 | +divv -3 | |
| 8 | +modv -2 | |
| 9 | +prec 14 | |
| 10 | +neg -85 | |
| 11 | +u8wrap 44 | |
| 12 | +i8wrap -128 | |
| 13 | +u32wrap 1 | |
| 14 | +u64>i 1 | |
| 15 | +i64< 1 | |
| 16 | +shl 1024 | |
| 17 | +shr -4 | |
| 18 | +ushr 15 | |
| 19 | +and 8 | |
| 20 | +or 15 | |
| 21 | +xor 6 | |
| 22 | +not -1 | |
| 23 | +real 85 | |
| 24 | +trunc -2 | |
| 25 | +nan 0 | |
| 26 | +rlt 1 | |
| 27 | +u64real 18 | |
| 28 | +bool 1 | |
| 29 | +shortcut 1 | |
| 30 | +global 42 | |
| 31 | +char 65 | |
| 32 | +utf8 233 | |
| 33 | +hexconst 255 | |
| 34 | +cut 44 | |
| 35 | +sext -1 |
| @@ -0,0 +1,74 @@ | ||
| 1 | +module Arith; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +const | |
| 5 | + K = 10; | |
| 6 | + M = K * 3 + 2; | |
| 7 | + Big = 0FFFFFFFFFFFFFFFFH; | |
| 8 | + | |
| 9 | +var g: I64; | |
| 10 | + | |
| 11 | +proc show(s: []U8; n: I64); | |
| 12 | +begin | |
| 13 | + Out.str(s); Out.str(" "); Out.int(n); Out.ln; | |
| 14 | +end; | |
| 15 | + | |
| 16 | +proc showb(s: []U8; t: BOOL); | |
| 17 | +begin | |
| 18 | + if t then show(s, 1); else show(s, 0); end; | |
| 19 | +end; | |
| 20 | + | |
| 21 | +proc main*; | |
| 22 | +var a, b: I64; u: U8; i8: I8; w: U32; x: U64; r: F64; t: BOOL; | |
| 23 | +begin | |
| 24 | + show("M", M); | |
| 25 | + a := 17; b := 5; | |
| 26 | + show("add", a + b); | |
| 27 | + show("sub", a - b); | |
| 28 | + show("mul", a * b); | |
| 29 | + show("div", -7 div 2); | |
| 30 | + show("mod", -7 mod 2); | |
| 31 | + show("divv", (0 - a) div b); | |
| 32 | + show("modv", (0 - a) mod b); | |
| 33 | + show("prec", 2 + 3 * 4); | |
| 34 | + show("neg", -a * b); | |
| 35 | + u := 200; | |
| 36 | + u := u + 100; | |
| 37 | + show("u8wrap", I64(u)); | |
| 38 | + i8 := 127; | |
| 39 | + i8 := i8 + 1; | |
| 40 | + show("i8wrap", I64(i8)); | |
| 41 | + w := 0FFFFFFFFH; | |
| 42 | + w := w + 2; | |
| 43 | + show("u32wrap", I64(w)); | |
| 44 | + x := Big; | |
| 45 | + showb("u64>i", x > 5); | |
| 46 | + showb("i64<", -1 < 5); | |
| 47 | + show("shl", 1 shl 10); | |
| 48 | + show("shr", -16 shr 2); | |
| 49 | + show("ushr", I64(U64(-16) shr 60)); | |
| 50 | + show("and", 12 & 10); | |
| 51 | + show("or", 12 | 3); | |
| 52 | + show("xor", 12 xor 10); | |
| 53 | + show("not", ~0); | |
| 54 | + r := F64(a) / 2.0; | |
| 55 | + show("real", I64(r * 10.0)); | |
| 56 | + r := -2.75; | |
| 57 | + show("trunc", I64(r)); | |
| 58 | + showb("nan", 0.0 / 0.0 = 0.0 / 0.0); | |
| 59 | + showb("rlt", 1.5 < 2.5); | |
| 60 | + show("u64real", I64(F64(x) / 1.0E18)); | |
| 61 | + t := (a > 3) and (b < 3); | |
| 62 | + if not t then show("bool", 1); end; | |
| 63 | + t := (a > 3) or (g div 0 = 1); | |
| 64 | + if t then show("shortcut", 1); end; | |
| 65 | + g := 42; | |
| 66 | + show("global", g); | |
| 67 | + show("char", 'A'); | |
| 68 | + show("utf8", 'é'); | |
| 69 | + show("hexconst", 0FFH); | |
| 70 | + show("cut", I64(U8(300))); | |
| 71 | + show("sext", I64(I8(U8(255)))); | |
| 72 | +end; | |
| 73 | + | |
| 74 | +end Arith. |
| @@ -0,0 +1 @@ | ||
| 1 | +TFFTTFTTTTFTTFTFTFTTTTT |
| @@ -0,0 +1,41 @@ | ||
| 1 | +module ArrayEq; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +type Colour = (red, green, blue); | |
| 5 | + | |
| 6 | +proc say(b: BOOL); | |
| 7 | +begin | |
| 8 | + if b then Out.str("T"); else Out.str("F"); end; | |
| 9 | +end; | |
| 10 | + | |
| 11 | +proc main*; | |
| 12 | +var | |
| 13 | + a, b: [4]I64; s: []I64; e: []I64; | |
| 14 | + w: [3]U16; c, d: [2]Colour; f: [3]BOOL; | |
| 15 | + m, n: [2]set of Colour; p, q: [2]^I64; x: I64; | |
| 16 | + t: [5]U8; | |
| 17 | +begin | |
| 18 | + a := [1, 2, 3, 4]; b := [1, 2, 3, 4]; | |
| 19 | + say(a = b); say(a # b); | |
| 20 | + b[3] := 5; | |
| 21 | + say(a = b); say(a # b); | |
| 22 | + s := a[0..3]; | |
| 23 | + say(s = a[0..3]); say(s = a); (* of different lengths *) | |
| 24 | + say(a[1..1] = e); say(e = s[0..0]); (* empty *) | |
| 25 | + w := [1, 256, 65535]; | |
| 26 | + say(w = [U16(1), 256, 65535]); say(w[2..3] = [U16(65535)]); | |
| 27 | + c := [red, blue]; d := [red, green]; | |
| 28 | + say(c = d); d[1] := blue; say(c = d); | |
| 29 | + f := [true, false, true]; | |
| 30 | + say(f[0..1] = f[2..3]); say(f[0..1] = [true, false]); | |
| 31 | + m := [{red}, {green, blue}]; n := m; | |
| 32 | + say(m = n); n[1] := {blue}; say(m = n); | |
| 33 | + p := [ADR(x), nil]; q := p; | |
| 34 | + say(p = q); q[1] := ADR(x); say(p = q); | |
| 35 | + t := [104, 101, 108, 108, 111]; | |
| 36 | + say(t = "hello"); say("hello" = t[0..5]); say("hell" = t[0..4]); | |
| 37 | + say("help" # t[0..4]); say("" = t[0..0]); | |
| 38 | + Out.ln; | |
| 39 | +end; | |
| 40 | + | |
| 41 | +end ArrayEq. |
| @@ -0,0 +1,5 @@ | ||
| 1 | +12 refused | |
| 2 | +main ends | |
| 3 | +third | |
| 4 | +second, which exits again | |
| 5 | +first |
| @@ -0,0 +1,41 @@ | ||
| 1 | +(* Rt.exit runs what Rt.atExit registered, the last first, each once, | |
| 2 | + then ends the program with main's status. *) | |
| 3 | +module AtExit; | |
| 4 | +import Out, Rt; | |
| 5 | + | |
| 6 | +proc first; | |
| 7 | +begin | |
| 8 | + Out.str("first\n"); | |
| 9 | +end; | |
| 10 | + | |
| 11 | +proc second; | |
| 12 | +begin | |
| 13 | + Out.str("second, which exits again\n"); | |
| 14 | + Rt.exit(5); (* the rest still run, once each; the status is now 5 *) | |
| 15 | +end; | |
| 16 | + | |
| 17 | +proc third; | |
| 18 | +begin | |
| 19 | + Out.str("third\n"); | |
| 20 | +end; | |
| 21 | + | |
| 22 | +proc nothing; | |
| 23 | +begin | |
| 24 | +end; | |
| 25 | + | |
| 26 | +proc main*: I64; | |
| 27 | +var i, full: I64; | |
| 28 | +begin | |
| 29 | + Rt.atExit(first); | |
| 30 | + Rt.atExit(second); | |
| 31 | + Rt.atExit(third); | |
| 32 | + full := 0; | |
| 33 | + for i := 1 to 40 do | |
| 34 | + if Rt.atExit(nothing) = Rt.Full then INC(full); end; | |
| 35 | + end; | |
| 36 | + Out.int(full); Out.str(" refused\n"); | |
| 37 | + Out.str("main ends\n"); | |
| 38 | + return 3; | |
| 39 | +end; | |
| 40 | + | |
| 41 | +end AtExit. |
| @@ -0,0 +1 @@ | ||
| 1 | +5 |
| @@ -0,0 +1 @@ | ||
| 1 | +First Second Bodies main 12 |
| @@ -0,0 +1,11 @@ | ||
| 1 | +module Bodies; | |
| 2 | +import Out, A := First, Second; | |
| 3 | + | |
| 4 | +proc main*; | |
| 5 | +begin | |
| 6 | + Out.str("main "); Out.int(A.count); Out.int(Second.count); Out.ln; | |
| 7 | +end; | |
| 8 | + | |
| 9 | +begin | |
| 10 | + Out.str("Bodies "); | |
| 11 | +end Bodies. |
| @@ -0,0 +1 @@ | ||
| 1 | +0123 | |
| \ No newline at end of file |
| @@ -0,0 +1,13 @@ | ||
| 1 | +module Bounds; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +proc main*; | |
| 5 | +var a: [4]I64; i: I64; | |
| 6 | +begin | |
| 7 | + for i := 0 to 4 do | |
| 8 | + a[i] := i; | |
| 9 | + Out.int(a[i]); | |
| 10 | + end; | |
| 11 | +end; | |
| 12 | + | |
| 13 | +end Bounds. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,8 @@ | ||
| 1 | +12345 | |
| 2 | +10 7 4 1 | |
| 3 | +0 4 8 | |
| 4 | +6 | |
| 5 | +3 | |
| 6 | +0 1 10 11 20 21 | |
| 7 | +4 | |
| 8 | +one two three many |
| @@ -0,0 +1,42 @@ | ||
| 1 | +module Control; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +proc main*; | |
| 5 | +var i, j, n: I64; u: U8; k: I8; | |
| 6 | +begin | |
| 7 | + for i := 1 to 5 do Out.int(i); end; Out.ln; | |
| 8 | + for i := 10 to 1 by -3 do Out.int(i); Out.str(" "); end; Out.ln; | |
| 9 | + for i := 0 to 10 by 4 do Out.int(i); Out.str(" "); end; Out.ln; | |
| 10 | + for i := 5 to 1 do Out.str("never"); end; | |
| 11 | + n := 0; | |
| 12 | + for u := 250 to 255 do n := n + 1; end; | |
| 13 | + Out.int(n); Out.ln; | |
| 14 | + n := 0; | |
| 15 | + for k := 120 to 127 by 3 do n := n + 1; end; | |
| 16 | + Out.int(n); Out.ln; | |
| 17 | + i := 0; | |
| 18 | + while i < 3 do | |
| 19 | + j := 0; | |
| 20 | + while true do | |
| 21 | + if j = 2 then break; end; | |
| 22 | + Out.int(i * 10 + j); Out.str(" "); | |
| 23 | + j := j + 1; | |
| 24 | + end; | |
| 25 | + i := i + 1; | |
| 26 | + end; | |
| 27 | + Out.ln; | |
| 28 | + i := 0; | |
| 29 | + repeat i := i + 1; if i = 4 then break; end; until i = 10; | |
| 30 | + Out.int(i); Out.ln; | |
| 31 | + for i := 1 to 4 do | |
| 32 | + if i = 1 then Out.str("one"); | |
| 33 | + elsif i = 2 then Out.str("two"); | |
| 34 | + elsif i = 3 then Out.str("three"); | |
| 35 | + else Out.str("many"); | |
| 36 | + end; | |
| 37 | + Out.str(" "); | |
| 38 | + end; | |
| 39 | + Out.ln; | |
| 40 | +end; | |
| 41 | + | |
| 42 | +end Control. |
| @@ -0,0 +1,5 @@ | ||
| 1 | +body body done | |
| 2 | +()30 | |
| 3 | +56 | |
| 4 | +[...*][...+**] | |
| 5 | +0 |
| @@ -0,0 +1,71 @@ | ||
| 1 | +module Defers; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +type Pair = record a, b: I64; end; | |
| 5 | + | |
| 6 | +var depth: I64; | |
| 7 | + | |
| 8 | +proc enter(s: []U8); | |
| 9 | +begin | |
| 10 | + Out.str(s); INC(depth); | |
| 11 | +end; | |
| 12 | + | |
| 13 | +proc leave(s: []U8); | |
| 14 | +begin | |
| 15 | + Out.str(s); DEC(depth); | |
| 16 | +end; | |
| 17 | + | |
| 18 | +proc real(x: F64): F64; | |
| 19 | +begin | |
| 20 | + enter("("); | |
| 21 | + defer leave(")"); | |
| 22 | + return x * 2.0; | |
| 23 | +end; | |
| 24 | + | |
| 25 | +proc pair(n: I64): Pair; | |
| 26 | +var p: Pair; | |
| 27 | +begin | |
| 28 | + defer p.a := 99; | |
| 29 | + p.a := n; p.b := n + 1; | |
| 30 | + return p; | |
| 31 | +end; | |
| 32 | + | |
| 33 | +proc begin_end(i: I64); | |
| 34 | +var k: I64; | |
| 35 | +begin | |
| 36 | + defer for k := 1 to i do Out.str("*"); end; | |
| 37 | + if i = 1 then return; end; | |
| 38 | + Out.str("+"); | |
| 39 | +end; | |
| 40 | + | |
| 41 | +proc nested; | |
| 42 | +var i, j: I64; | |
| 43 | +begin | |
| 44 | + for i := 1 to 2 do | |
| 45 | + enter("["); | |
| 46 | + defer leave("]"); | |
| 47 | + defer begin_end(i); | |
| 48 | + j := 0; | |
| 49 | + while true do | |
| 50 | + defer Out.str("."); | |
| 51 | + INC(j); | |
| 52 | + if j = 3 then break; end; | |
| 53 | + end; | |
| 54 | + end; | |
| 55 | +end; | |
| 56 | + | |
| 57 | +proc main*; | |
| 58 | +var p: Pair; | |
| 59 | +begin | |
| 60 | + Out.int(I64(real(1.5) * 10.0)); Out.ln; | |
| 61 | + p := pair(5); | |
| 62 | + Out.int(p.a); Out.int(p.b); Out.ln; | |
| 63 | + nested; | |
| 64 | + Out.ln; | |
| 65 | + Out.int(depth); Out.ln; | |
| 66 | +end; | |
| 67 | + | |
| 68 | +begin | |
| 69 | + defer Out.str("body done\n"); | |
| 70 | + Out.str("body "); | |
| 71 | +end Defers. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +an instance of Loud, of size 1 | |
| 2 | +an empty list | |
| 3 | +in main, Ones has size 1 | |
| 4 | +sky not red | |
| 5 | +rose red | |
| 6 | +grass - |
| @@ -0,0 +1,34 @@ | ||
| 1 | +module FirstUse; | |
| 2 | +import Out, Str, Heap, Table := Map([]U8, Colour, Str.hash, Str.eq), | |
| 3 | + Ints := List(I64), More := List(I64), Never := Loud(I64), Ones := Loud(U8); | |
| 4 | + | |
| 5 | +type Colour = (red, green, blue); | |
| 6 | + | |
| 7 | +var names: Table.Map; (* Table is made here, after Colour *) | |
| 8 | + | |
| 9 | +proc show(k: []U8); | |
| 10 | +var c: Colour; found: BOOL; | |
| 11 | +begin | |
| 12 | + c, found := Table.get(ADR(names), k); | |
| 13 | + Out.str(k); | |
| 14 | + if not found then Out.str(" -"); elsif c = red then Out.str(" red"); else Out.str(" not red"); end; | |
| 15 | + Out.ln; | |
| 16 | +end; | |
| 17 | + | |
| 18 | +(* Ones is first used in a procedure, and made before its code *) | |
| 19 | +proc main*; | |
| 20 | +var a: Ints.List; b: More.List; | |
| 21 | +begin | |
| 22 | + a := b; (* two imports, one instance *) | |
| 23 | + if a.head = nil then Out.str("an empty list\n"); end; | |
| 24 | + Out.str("in main, Ones has size "); Out.int(Ones.size); Out.ln; | |
| 25 | + show("sky"); | |
| 26 | + show("rose"); | |
| 27 | + show("grass"); | |
| 28 | +end; | |
| 29 | + | |
| 30 | +begin | |
| 31 | + Table.init(ADR(names), Heap.heap); | |
| 32 | + Table.put(ADR(names), "rose", red); | |
| 33 | + Table.put(ADR(names), "sky", blue); | |
| 34 | +end FirstUse. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +8 2 true | |
| 2 | +8 1 | |
| 3 | +abtrue | |
| 4 | +[] false | |
| 5 | +157 152 -1 | |
| 6 | +{ BEEF } x18446744073709551615 |
| @@ -0,0 +1,30 @@ | ||
| 1 | +module Generic; | |
| 2 | +import Fmt, Buf, Str, Heap, Stack, Ints := List(I64), More := List(I64), Strs := List([]U8); | |
| 3 | + | |
| 4 | +proc twice(x: I64): I64; begin return x * 2; end; | |
| 5 | + | |
| 6 | +proc main*; | |
| 7 | +var l: Strs.List; v: I64; s: []U8; ok: BOOL; b: Buf.Buf; n: ^Ints.Node; | |
| 8 | +begin | |
| 9 | + ok := Ints.push(ADR(Stack.s), 7); | |
| 10 | + ok := More.push(ADR(Stack.s), 8); | |
| 11 | + Fmt.print("{} {} {}\n", [Fmt.int(Stack.top()), Fmt.int(Stack.s.len), Fmt.bool(ok)]); | |
| 12 | + n := Stack.s.head; | |
| 13 | + v, ok := Ints.pop(ADR(Stack.s)); | |
| 14 | + Fmt.print("{} {}\n", [Fmt.int(v), Fmt.int(Stack.s.len)]); | |
| 15 | + Strs.init(ADR(l), Heap.heap); | |
| 16 | + ok := Strs.push(ADR(l), "b"); | |
| 17 | + ok := Strs.push(ADR(l), "a"); | |
| 18 | + s, ok := Strs.pop(ADR(l)); | |
| 19 | + Fmt.print("{}{}{}\n", [Fmt.str(s), Fmt.str(l.head^.val), Fmt.bool(ok)]); | |
| 20 | + s, ok := Strs.pop(ADR(l)); | |
| 21 | + s, ok := Strs.pop(ADR(l)); | |
| 22 | + Fmt.print("[{}] {}\n", [Fmt.str(s), Fmt.bool(ok)]); | |
| 23 | + Buf.init(ADR(b), Heap.heap); | |
| 24 | + for v := 1 to 40 do Fmt.write(ADR(b), "{},", [Fmt.int(v * v)]); end; | |
| 25 | + Fmt.print("{} {} {}\n", [Fmt.int(b.len), Fmt.int(Str.find(Buf.bytes(ADR(b)), "1600")), Fmt.int(Str.cmp("ab", "b"))]); | |
| 26 | + Buf.done(ADR(b)); | |
| 27 | + Fmt.print("{{ {} }} {}{}\n", [Fmt.hex(48879), Fmt.char('x'), Fmt.uint(0FFFFFFFFFFFFFFFFH)]); | |
| 28 | +end; | |
| 29 | + | |
| 30 | +end Generic. |
| @@ -0,0 +1,10 @@ | ||
| 1 | +nil | |
| 2 | +nil | |
| 3 | +nil | |
| 4 | +nil | |
| 5 | +nil | |
| 6 | +nil | |
| 7 | +a block | |
| 8 | +aligned | |
| 9 | +a block | |
| 10 | +freeing it again |
| @@ -0,0 +1,34 @@ | ||
| 1 | +(* The heap refuses bad sizes and alignments, and stops the program | |
| 2 | + when a block is freed twice. *) | |
| 3 | +module HeapCheck; | |
| 4 | +import Out, Heap, Mem; | |
| 5 | + | |
| 6 | +proc show(p: ^U8); | |
| 7 | +begin | |
| 8 | + if p = nil then Out.str("nil\n"); else Out.str("a block\n"); end; | |
| 9 | +end; | |
| 10 | + | |
| 11 | +proc main*; | |
| 12 | +var p, q: ^U8; | |
| 13 | +begin | |
| 14 | + show(Mem.alloc(Heap.heap, -1, 8)); | |
| 15 | + show(Mem.alloc(Heap.heap, 1 shl 60, 8)); | |
| 16 | + show(Mem.alloc(Heap.heap, 7FFFFFFFFFFFFFF0H, 8)); | |
| 17 | + show(Mem.alloc(Heap.heap, 10, 3)); | |
| 18 | + show(Mem.alloc(Heap.heap, 10, 0)); | |
| 19 | + show(Mem.alloc(Heap.heap, 10, 8192)); | |
| 20 | + p := Mem.alloc(Heap.heap, 10, 64); | |
| 21 | + show(p); | |
| 22 | + if I64(p) mod 64 = 0 then Out.str("aligned\n"); end; | |
| 23 | + Mem.free(Heap.heap, p); | |
| 24 | + q := Mem.alloc(Heap.heap, 100000, 8); | |
| 25 | + show(q); | |
| 26 | + Mem.free(Heap.heap, q); | |
| 27 | + p := Mem.alloc(Heap.heap, 24, 8); | |
| 28 | + Mem.free(Heap.heap, p); | |
| 29 | + Out.str("freeing it again\n"); | |
| 30 | + Mem.free(Heap.heap, p); | |
| 31 | + Out.str("not reached\n"); | |
| 32 | +end; | |
| 33 | + | |
| 34 | +end HeapCheck. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1 @@ | ||
| 1 | +freeing a stray pointer |
| @@ -0,0 +1,14 @@ | ||
| 1 | +(* Freeing what the heap never gave out stops the program. *) | |
| 2 | +module HeapStray; | |
| 3 | +import Out, Heap, Mem; | |
| 4 | + | |
| 5 | +var a: [4]I64; | |
| 6 | + | |
| 7 | +proc main*; | |
| 8 | +begin | |
| 9 | + Out.str("freeing a stray pointer\n"); | |
| 10 | + Mem.free(Heap.heap, ^U8(ADR(a[2]))); | |
| 11 | + Out.str("not reached\n"); | |
| 12 | +end; | |
| 13 | + | |
| 14 | +end HeapStray. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,8 @@ | ||
| 1 | +023 2 0 in out sub sup ne eq | |
| 2 | +13 10 1 2 lt green other | |
| 3 | +120 0 2 | |
| 4 | +47mid | |
| 5 | +24 | |
| 6 | +50 LLCBA | |
| 7 | +-1 LLDBA | |
| 8 | +3 | |
| \ No newline at end of file |
| @@ -0,0 +1,95 @@ | ||
| 1 | +module Kinds; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +type | |
| 5 | + Color* = (red, green, blue, black); | |
| 6 | + Colors* = set of Color; | |
| 7 | + Cell = record ch: U8; attr: U8; fg: Color; end; | |
| 8 | + Point = record x, y: I64; name: []U8; end; | |
| 9 | + Line = record a, b: Point; end; | |
| 10 | + | |
| 11 | +var log: [8]U8; nlog: I64; | |
| 12 | + | |
| 13 | +proc note(c: U8); | |
| 14 | +begin | |
| 15 | + log[nlog] := c; | |
| 16 | + INC(nlog); | |
| 17 | +end; | |
| 18 | + | |
| 19 | +proc show(s: Colors); | |
| 20 | +var c: Color; | |
| 21 | +begin | |
| 22 | + for c := red to black do | |
| 23 | + if c in s then Out.int(I64(c)); end; | |
| 24 | + end; | |
| 25 | + Out.str(" "); | |
| 26 | +end; | |
| 27 | + | |
| 28 | +proc name(c: Color): []U8; | |
| 29 | +begin | |
| 30 | + match c of | |
| 31 | + | red: return "red"; | |
| 32 | + | green: return "green"; | |
| 33 | + | else: return "other"; | |
| 34 | + end; | |
| 35 | +end; | |
| 36 | + | |
| 37 | +proc deferred(n: I64): I64; | |
| 38 | +var i: I64; | |
| 39 | +begin | |
| 40 | + defer note('A'); | |
| 41 | + defer note('B'); | |
| 42 | + for i := 1 to 3 do | |
| 43 | + defer note('L'); | |
| 44 | + if i = 2 then break; end; | |
| 45 | + end; | |
| 46 | + if n > 0 then | |
| 47 | + defer note('C'); | |
| 48 | + return n * 10; | |
| 49 | + end; | |
| 50 | + note('D'); | |
| 51 | + return -1; | |
| 52 | +end; | |
| 53 | + | |
| 54 | +proc mid(a, b: Point): Point; | |
| 55 | +begin | |
| 56 | + return {x: (a.x + b.x) div 2, y: (a.y + b.y) div 2, name: "mid"}; | |
| 57 | +end; | |
| 58 | + | |
| 59 | +proc main*; | |
| 60 | +var s, t: Colors; c: Color; cell: Cell; p: Point; l: Line; r: I64; one: Colors; | |
| 61 | +begin | |
| 62 | + s := {red, blue}; | |
| 63 | + t := {blue, black}; | |
| 64 | + show(s + t); show(s * t); show(s - t); show({}); | |
| 65 | + if red in s then Out.str("in "); end; | |
| 66 | + if not (green in s) then Out.str("out "); end; | |
| 67 | + if s * t <= t then Out.str("sub "); end; | |
| 68 | + if s + t >= s then Out.str("sup "); end; | |
| 69 | + if s # t then Out.str("ne "); end; | |
| 70 | + if s = {blue, red} then Out.str("eq"); end; | |
| 71 | + Out.ln; | |
| 72 | + c := green; | |
| 73 | + one := {c, black}; | |
| 74 | + show(one); | |
| 75 | + Out.int(I64(U8(one))); Out.str(" "); | |
| 76 | + Out.int(SIZE(Colors)); Out.str(" "); | |
| 77 | + Out.int(I64(Color(2))); Out.str(" "); | |
| 78 | + if c < blue then Out.str("lt "); end; | |
| 79 | + Out.str(name(c)); Out.str(" "); Out.str(name(black)); Out.ln; | |
| 80 | + cell := {ch: 'x', fg: blue}; | |
| 81 | + Out.int(I64(cell.ch)); Out.str(" "); Out.int(I64(cell.attr)); Out.str(" "); Out.int(I64(cell.fg)); Out.ln; | |
| 82 | + p := mid({x: 2, y: 4}, {y: 10, x: 6}); | |
| 83 | + Out.int(p.x); Out.int(p.y); Out.str(p.name); Out.ln; | |
| 84 | + l := {a: {x: 1, y: 2}, b: p}; | |
| 85 | + Out.int(l.a.y); Out.int(l.b.x); Out.ln; | |
| 86 | + r := deferred(5); | |
| 87 | + Out.int(r); Out.str(" "); Out.str(log[0..nlog]); Out.ln; | |
| 88 | + nlog := 0; | |
| 89 | + r := deferred(0); | |
| 90 | + Out.int(r); Out.str(" "); Out.str(log[0..nlog]); Out.ln; | |
| 91 | + Out.int(I64(Color(I64(c) + 2))); | |
| 92 | + c := Color(nlog); | |
| 93 | +end; | |
| 94 | + | |
| 95 | +end Kinds. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,2 @@ | ||
| 1 | +341 entries, 341 of them, summing 6658308 | |
| 2 | +walked 341, summing 6658308 |
| @@ -0,0 +1,56 @@ | ||
| 1 | +(* Map's remove and next, against an array that holds the same: keys | |
| 2 | + hashed into runs of eight, so that removing moves entries back, | |
| 3 | + around the end of the slots too. *) | |
| 4 | +module MapRemove; | |
| 5 | +import Fmt, Heap, Rt, Ints := Map(I64, I64, near, same); | |
| 6 | + | |
| 7 | +const N = 500; | |
| 8 | + | |
| 9 | +proc near(k: I64): U64; | |
| 10 | +begin | |
| 11 | + return U64(k div 8 * 977); | |
| 12 | +end; | |
| 13 | + | |
| 14 | +proc same(a, b: I64): BOOL; | |
| 15 | +begin | |
| 16 | + return a = b; | |
| 17 | +end; | |
| 18 | + | |
| 19 | +proc main*; | |
| 20 | +var | |
| 21 | + m: Ints.Map; want: [N]I64; i, k, v, n, sum, seed: I64; | |
| 22 | + found, _ok: BOOL; | |
| 23 | +begin | |
| 24 | + Ints.init(ADR(m), Heap.heap); | |
| 25 | + seed := 1; | |
| 26 | + for i := 1 to 20000 do | |
| 27 | + seed := (seed * 1103515245 + 12345) & 7FFFFFFFH; | |
| 28 | + k := seed mod N; | |
| 29 | + if seed div N mod 3 = 0 then | |
| 30 | + if Ints.remove(ADR(m), k) # (want[k] # 0) then Rt.stop("remove: wrong answer"); end; | |
| 31 | + want[k] := 0; | |
| 32 | + else | |
| 33 | + _ok := Ints.put(ADR(m), k, i); | |
| 34 | + want[k] := i; | |
| 35 | + end; | |
| 36 | + end; | |
| 37 | + for k := 0 to N - 1 do | |
| 38 | + v, found := Ints.get(ADR(m), k); | |
| 39 | + if (found # (want[k] # 0)) or (v # want[k]) then Rt.stop("get: not what was put"); end; | |
| 40 | + if found then INC(n); INC(sum, v); end; | |
| 41 | + end; | |
| 42 | + if Ints.remove(ADR(m), N) then Rt.stop("remove: a key never put"); end; | |
| 43 | + Fmt.print("{} entries, {} of them, summing {}\n", [Fmt.int(m.len), Fmt.int(n), Fmt.int(sum)]); | |
| 44 | + (* the walk sees each entry once *) | |
| 45 | + n := 0; sum := 0; | |
| 46 | + i, k, v := Ints.next(ADR(m), 0); | |
| 47 | + while i >= 0 do | |
| 48 | + if want[k] # v then Rt.stop("next: not what was put"); end; | |
| 49 | + want[k] := 0; | |
| 50 | + INC(n); INC(sum, v); | |
| 51 | + i, k, v := Ints.next(ADR(m), i); | |
| 52 | + end; | |
| 53 | + Fmt.print("walked {}, summing {}\n", [Fmt.int(n), Fmt.int(sum)]); | |
| 54 | +end; | |
| 55 | + | |
| 56 | +end MapRemove. |
| @@ -0,0 +1,2 @@ | ||
| 1 | +14 7 DEADBEF0 -5 9 | |
| 2 | +240 |
| @@ -0,0 +1,23 @@ | ||
| 1 | +module PackedFields; | |
| 2 | +(* A packed record's fields are read and written wherever they sit *) | |
| 3 | +import Out; | |
| 4 | + | |
| 5 | +type | |
| 6 | + Header = packed record kind: U8; len: U32; big: I64; tag: U8; end; | |
| 7 | + | |
| 8 | +proc main*; | |
| 9 | +var h, g: Header; b: ^U8; | |
| 10 | +begin | |
| 11 | + h.kind := 7; h.len := 0DEADBEEFH; h.big := -5; h.tag := 9; | |
| 12 | + INC(h.len); | |
| 13 | + g := h; | |
| 14 | + Out.int(SIZE(Header)); Out.str(" "); | |
| 15 | + Out.int(I64(g.kind)); Out.str(" "); | |
| 16 | + Out.hex(U64(g.len), 8); Out.str(" "); | |
| 17 | + Out.int(g.big); Out.str(" "); | |
| 18 | + Out.int(I64(g.tag)); Out.ln; | |
| 19 | + b := ADR(g.kind); | |
| 20 | + Out.int(I64(b[1])); Out.ln; | |
| 21 | +end; | |
| 22 | + | |
| 23 | +end PackedFields. |
| @@ -0,0 +1,5 @@ | ||
| 1 | +42 | |
| 2 | +2 whole | |
| 3 | +2 part | |
| 4 | +3 part | |
| 5 | +65 66 67 -65 |
| @@ -0,0 +1,42 @@ | ||
| 1 | +module PassOn; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +type Pair = record a, b: I64; end; | |
| 5 | + | |
| 6 | +proc one(n: I64): I64; | |
| 7 | +begin | |
| 8 | + return n * 2; | |
| 9 | +end; | |
| 10 | + | |
| 11 | +proc two(n: I64): (I64, BOOL); | |
| 12 | +begin | |
| 13 | + return n div 7, n mod 7 = 0; | |
| 14 | +end; | |
| 15 | + | |
| 16 | +proc three(n: I64): (U8, Pair, I64); | |
| 17 | +begin | |
| 18 | + return U8(n), {a: n + 1, b: n + 2}, -n; | |
| 19 | +end; | |
| 20 | + | |
| 21 | +(* each passes on what the one below returns *) | |
| 22 | +proc one1(n: I64): I64; begin return one(n); end; | |
| 23 | +proc one2(n: I64): I64; begin return one1(n); end; | |
| 24 | +proc two1(n: I64): (I64, BOOL); begin return two(n + 1); end; | |
| 25 | +proc two2(n: I64): (I64, BOOL); begin return two1(n + 1); end; | |
| 26 | +proc three1(n: I64): (U8, Pair, I64); begin return three(n); end; | |
| 27 | +proc three2(n: I64): (U8, Pair, I64); begin return three1(n); end; | |
| 28 | + | |
| 29 | +proc main*; | |
| 30 | +var i, q: I64; z: BOOL; c: U8; p: Pair; | |
| 31 | +begin | |
| 32 | + Out.int(one2(21)); Out.ln; | |
| 33 | + for i := 0 to 2 do | |
| 34 | + q, z := two2(i * 5 + 12); | |
| 35 | + Out.int(q); Out.str(" "); if z then Out.str("whole"); else Out.str("part"); end; Out.ln; | |
| 36 | + end; | |
| 37 | + c, p, i := three2(65); | |
| 38 | + Out.int(I64(c)); Out.str(" "); Out.int(p.a); Out.str(" "); Out.int(p.b); | |
| 39 | + Out.str(" "); Out.int(i); Out.ln; | |
| 40 | +end; | |
| 41 | + | |
| 42 | +end PassOn. |
| @@ -0,0 +1,2 @@ | ||
| 1 | +-7 div 2 = -3, -7 mod 2 = -1 | |
| 2 | +0 wrong |
| @@ -0,0 +1,68 @@ | ||
| 1 | +(* div, mod and * by a power of two are shifts; they must agree with | |
| 2 | + idiv and imul, which a divisor in a variable still gets. *) | |
| 3 | +module Pow2; | |
| 4 | +import Out; | |
| 5 | + | |
| 6 | +var bad: I64; | |
| 7 | + | |
| 8 | +proc check(s: []U8; x, got, want: I64); | |
| 9 | +begin | |
| 10 | + if got # want then | |
| 11 | + Out.str(s); Out.str(" "); Out.int(x); Out.str(": "); | |
| 12 | + Out.int(got); Out.str(" # "); Out.int(want); Out.ln; | |
| 13 | + bad := bad + 1; | |
| 14 | + end; | |
| 15 | +end; | |
| 16 | + | |
| 17 | +proc i64s(x: I64); | |
| 18 | +var d1, d2, d8, d62: I64; | |
| 19 | +begin | |
| 20 | + d1 := 1; d2 := 2; d8 := 8; d62 := 4000000000000000H; | |
| 21 | + check("div 1", x, x div 1, x div d1); | |
| 22 | + check("mod 1", x, x mod 1, x mod d1); | |
| 23 | + check("div 2", x, x div 2, x div d2); | |
| 24 | + check("mod 2", x, x mod 2, x mod d2); | |
| 25 | + check("div 8", x, x div 8, x div d8); | |
| 26 | + check("mod 8", x, x mod 8, x mod d8); | |
| 27 | + check("div 2^62", x, x div 4000000000000000H, x div d62); | |
| 28 | + check("mod 2^62", x, x mod 4000000000000000H, x mod d62); | |
| 29 | + check("* 8", x, x * 8, x * d8); | |
| 30 | + check("div -8", x, x div (0 - 8), x div (0 - d8)); | |
| 31 | +end; | |
| 32 | + | |
| 33 | +proc u64s(x: U64); | |
| 34 | +var d2, d8, d62: U64; | |
| 35 | +begin | |
| 36 | + d2 := 2; d8 := 8; d62 := 4000000000000000H; | |
| 37 | + check("u div 2", I64(x), I64(x div 2), I64(x div d2)); | |
| 38 | + check("u mod 2", I64(x), I64(x mod 2), I64(x mod d2)); | |
| 39 | + check("u div 8", I64(x), I64(x div 8), I64(x div d8)); | |
| 40 | + check("u mod 8", I64(x), I64(x mod 8), I64(x mod d8)); | |
| 41 | + check("u div 2^62", I64(x), I64(x div 4000000000000000H), I64(x div d62)); | |
| 42 | + check("u mod 2^62", I64(x), I64(x mod 4000000000000000H), I64(x mod d62)); | |
| 43 | +end; | |
| 44 | + | |
| 45 | +proc main*; | |
| 46 | +var i: I64; b: I8; d: I8; w: U8; dw: U8; | |
| 47 | +begin | |
| 48 | + for i := -300 to 300 do i64s(i); u64s(U64(i)); end; | |
| 49 | + i64s(07FFFFFFFFFFFFFFFH); i64s(-07FFFFFFFFFFFFFFFH - 1); | |
| 50 | + i64s(4000000000000001H); i64s(-4000000000000001H); | |
| 51 | + u64s(0FFFFFFFFFFFFFFFFH); u64s(8000000000000000H); | |
| 52 | + d := 8; dw := 8; | |
| 53 | + for i := -128 to 127 do | |
| 54 | + b := I8(i); w := U8(i + 128); | |
| 55 | + check("i8 div 8", i, I64(b div 8), I64(b div d)); | |
| 56 | + check("i8 mod 8", i, I64(b mod 8), I64(b mod d)); | |
| 57 | + check("i8 * 8", i, I64(b * 8), I64(b * d)); | |
| 58 | + check("u8 div 8", i, I64(w div 8), I64(w div dw)); | |
| 59 | + check("u8 mod 8", i, I64(w mod 8), I64(w mod dw)); | |
| 60 | + check("u8 * 8", i, I64(w * 8), I64(w * dw)); | |
| 61 | + end; | |
| 62 | + i := -7; | |
| 63 | + Out.str("-7 div 2 = "); Out.int(i div 2); | |
| 64 | + Out.str(", -7 mod 2 = "); Out.int(i mod 2); Out.ln; | |
| 65 | + Out.int(bad); Out.str(" wrong\n"); | |
| 66 | +end; | |
| 67 | + | |
| 68 | +end Pow2. |
| @@ -0,0 +1,13 @@ | ||
| 1 | +parity ok | |
| 2 | +21 | |
| 3 | +10 11 21 | |
| 4 | +22 | |
| 5 | +7 12 | |
| 6 | +same | |
| 7 | +nil | |
| 8 | +3245 | |
| 9 | +2432902008176640000 | |
| 10 | +95 5 | |
| 11 | +0 | |
| 12 | +16 0 | |
| 13 | +15 |
| @@ -0,0 +1,117 @@ | ||
| 1 | +module Procs; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +type | |
| 5 | + Pair = record x, y: I64; end; | |
| 6 | + Op = proc(a, b: I64): I64; | |
| 7 | + Big = record a: [10]I64; end; | |
| 8 | + | |
| 9 | +proc even(n: I64): BOOL; forward; | |
| 10 | + | |
| 11 | +proc odd(n: I64): BOOL; | |
| 12 | +begin | |
| 13 | + if n = 0 then return false; end; | |
| 14 | + return even(n - 1); | |
| 15 | +end; | |
| 16 | + | |
| 17 | +proc even(n: I64): BOOL; | |
| 18 | +begin | |
| 19 | + if n = 0 then return true; end; | |
| 20 | + return odd(n - 1); | |
| 21 | +end; | |
| 22 | + | |
| 23 | +proc swap(var a, b: I64); | |
| 24 | +var t: I64; | |
| 25 | +begin | |
| 26 | + t := a; a := b; b := t; | |
| 27 | +end; | |
| 28 | + | |
| 29 | +proc bump(p: Pair): Pair; | |
| 30 | +begin | |
| 31 | + p.x := p.x + 1; | |
| 32 | + p.y := p.y + 1; | |
| 33 | + return p; | |
| 34 | +end; | |
| 35 | + | |
| 36 | +proc add(a, b: I64): I64; begin return a + b; end; | |
| 37 | +proc mul(a, b: I64): I64; begin return a * b; end; | |
| 38 | + | |
| 39 | +proc apply(f: Op; a, b: I64): I64; | |
| 40 | +begin | |
| 41 | + return f(a, b); | |
| 42 | +end; | |
| 43 | + | |
| 44 | +proc many(a, b, c, d, e, f, g, h: I64; x: F64; i: I64; y: F64): I64; | |
| 45 | +begin | |
| 46 | + return a + 2 * b + 3 * c + 4 * d + 5 * e + 6 * f + 7 * g + 8 * h + I64(x) * 100 + 9 * i + I64(y) * 1000; | |
| 47 | +end; | |
| 48 | + | |
| 49 | +proc fact(n: I64): I64; | |
| 50 | +begin | |
| 51 | + if n <= 1 then return 1; end; | |
| 52 | + return n * fact(n - 1); | |
| 53 | +end; | |
| 54 | + | |
| 55 | +proc fill(var b: Big; v: I64); | |
| 56 | +var i: I64; | |
| 57 | +begin | |
| 58 | + for i := 0 to 9 do b.a[i] := v + i; end; | |
| 59 | +end; | |
| 60 | + | |
| 61 | +proc total(b: Big): I64; | |
| 62 | +var i, s: I64; | |
| 63 | +begin | |
| 64 | + s := 0; | |
| 65 | + for i := 0 to 9 do s := s + b.a[i]; end; | |
| 66 | + b.a[0] := 1000; | |
| 67 | + return s; | |
| 68 | +end; | |
| 69 | + | |
| 70 | +proc noresult(n: I64): I64; | |
| 71 | +begin | |
| 72 | + if n > 100 then return 1; end; | |
| 73 | +end; | |
| 74 | + | |
| 75 | +proc mk(n: I64): Big; | |
| 76 | +var b: Big; | |
| 77 | +begin | |
| 78 | + fill(b, n); | |
| 79 | + return b; | |
| 80 | +end; | |
| 81 | + | |
| 82 | +proc mkzero(n: I64): Big; | |
| 83 | +begin | |
| 84 | +end; | |
| 85 | + | |
| 86 | +proc fsum(a, b: F64): F64; | |
| 87 | +begin | |
| 88 | + return a + b; | |
| 89 | +end; | |
| 90 | + | |
| 91 | +proc main*: I64; | |
| 92 | +var a, b: I64; p, q: Pair; f: Op; bg: Big; | |
| 93 | +begin | |
| 94 | + if even(10) and odd(7) and not even(3) then Out.str("parity ok"); Out.ln; end; | |
| 95 | + a := 1; b := 2; | |
| 96 | + swap(a, b); | |
| 97 | + Out.int(a); Out.int(b); Out.ln; | |
| 98 | + p.x := 10; p.y := 20; | |
| 99 | + q := bump(p); | |
| 100 | + Out.int(p.x); Out.str(" "); Out.int(q.x); Out.str(" "); Out.int(q.y); Out.ln; | |
| 101 | + Out.int(bump(bump(p)).y); Out.ln; | |
| 102 | + f := add; | |
| 103 | + Out.int(apply(f, 3, 4)); Out.str(" "); Out.int(apply(mul, 3, 4)); Out.ln; | |
| 104 | + if f = add then Out.str("same"); Out.ln; end; | |
| 105 | + f := nil; | |
| 106 | + if f = nil then Out.str("nil"); Out.ln; end; | |
| 107 | + Out.int(many(1, 1, 1, 1, 1, 1, 1, 1, 2.5, 1, 3.9)); Out.ln; | |
| 108 | + Out.int(fact(20)); Out.ln; | |
| 109 | + fill(bg, 5); | |
| 110 | + Out.int(total(bg)); Out.str(" "); Out.int(bg.a[0]); Out.ln; | |
| 111 | + Out.int(noresult(5)); Out.ln; | |
| 112 | + Out.int(mk(7).a[9]); Out.str(" "); Out.int(mkzero(1).a[3]); Out.ln; | |
| 113 | + Out.int(I64(fsum(1.25, 2.5) * 4.0)); Out.ln; | |
| 114 | + return 7; | |
| 115 | +end; | |
| 116 | + | |
| 117 | +end Procs. |
| @@ -0,0 +1 @@ | ||
| 1 | +7 |
| @@ -0,0 +1,12 @@ | ||
| 1 | +7506AC5B262CA1FF | |
| 2 | +3FB999999999999A | |
| 3 | +FFFFFFFFFFFFF | |
| 4 | +1 | |
| 5 | +1 | |
| 6 | +0 | |
| 7 | +0 | |
| 8 | +7FEFFFFFFFFFFFFF | |
| 9 | +4340000000000000 | |
| 10 | +4340000000000002 | |
| 11 | +3FF0000000000000 | |
| 12 | +3FF0000000000001 |
| @@ -0,0 +1,34 @@ | ||
| 1 | +(* Real literals read to the nearest F64, ties to the even one: their | |
| 2 | + bits, for numbers a reader of decimals easily gets one off. *) | |
| 3 | +module RealRead; | |
| 4 | +import Fmt; | |
| 5 | + | |
| 6 | +proc bits(x: F64): U64; | |
| 7 | +var p: ^U64; | |
| 8 | +begin | |
| 9 | + p := ^U64(ADR(x)); | |
| 10 | + return p^; | |
| 11 | +end; | |
| 12 | + | |
| 13 | +proc show(x: F64); | |
| 14 | +begin | |
| 15 | + Fmt.print("{}\n", [Fmt.hex(bits(x))]); | |
| 16 | +end; | |
| 17 | + | |
| 18 | +proc main*; | |
| 19 | +begin | |
| 20 | + show(5.319372648326541E255); | |
| 21 | + show(0.1); | |
| 22 | + show(2.2250738585072011E-308); (* just below the least normal *) | |
| 23 | + show(4.9E-324); (* the least F64 *) | |
| 24 | + show(2.4703282292062328E-324); (* just over half of it: up *) | |
| 25 | + show(2.4703282292062327E-324); (* just under: 0 *) | |
| 26 | + show(1.0E-400); | |
| 27 | + show(1.7976931348623157E308); (* the largest *) | |
| 28 | + show(9007199254740993.0); (* 2^53 + 1, a tie: down to even *) | |
| 29 | + show(9007199254740995.0); (* 2^53 + 3, a tie: up to even *) | |
| 30 | + show(1.00000000000000011102230246251565404236316680908203125); (* 1 + 2^-53, a tie *) | |
| 31 | + show(1.00000000000000011102230246251565404236316680908203126); | |
| 32 | +end; | |
| 33 | + | |
| 34 | +end RealRead. |
| @@ -0,0 +1 @@ | ||
| 1 | +6 3 0 | |
| \ No newline at end of file |
| @@ -0,0 +1,15 @@ | ||
| 1 | +module SliceBounds; | |
| 2 | +(* A slice must have 0 <= lo <= hi <= the length *) | |
| 3 | +import Out; | |
| 4 | + | |
| 5 | +proc main*; | |
| 6 | +var a: [8]I64; s: []I64; lo: I64; | |
| 7 | +begin | |
| 8 | + s := a[0..8]; | |
| 9 | + for lo := 0 to 9 by 3 do | |
| 10 | + Out.int(LEN(s[lo..6])); | |
| 11 | + Out.str(" "); | |
| 12 | + end; | |
| 13 | +end; | |
| 14 | + | |
| 15 | +end SliceBounds. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1 @@ | ||
| 1 | +0123 | |
| \ No newline at end of file |
| @@ -0,0 +1,15 @@ | ||
| 1 | +module SliceIndex; | |
| 2 | +(* An index checked against a slice's length, which is in memory *) | |
| 3 | +import Out; | |
| 4 | + | |
| 5 | +proc main*; | |
| 6 | +var a: [8]I64; s: []I64; i: I64; | |
| 7 | +begin | |
| 8 | + s := a[2..5]; | |
| 9 | + for i := 0 to 3 do | |
| 10 | + Out.int(i); | |
| 11 | + s[i] := i; | |
| 12 | + end; | |
| 13 | +end; | |
| 14 | + | |
| 15 | +end SliceIndex. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1 @@ | ||
| 1 | +2 0 | |
| \ No newline at end of file |
| @@ -0,0 +1,16 @@ | ||
| 1 | +module SlicePtrBackwards; | |
| 2 | +(* A slice of a pointer isn't checked against a length, but it can't | |
| 3 | + run backwards *) | |
| 4 | +import Out; | |
| 5 | + | |
| 6 | +proc main*; | |
| 7 | +var a: [8]U8; p: ^U8; hi: I64; | |
| 8 | +begin | |
| 9 | + p := ADR(a[0]); | |
| 10 | + for hi := 4 to 0 by -2 do | |
| 11 | + Out.int(LEN(p[2..hi])); | |
| 12 | + Out.str(" "); | |
| 13 | + end; | |
| 14 | +end; | |
| 15 | + | |
| 16 | +end SlicePtrBackwards. |
| @@ -0,0 +1 @@ | ||
| 1 | +2 |
| @@ -0,0 +1,4 @@ | ||
| 1 | +Bo 7 | |
| 2 | +Di 23 | |
| 3 | +Ana 41 | |
| 4 | +Cy 90 |
| @@ -0,0 +1,51 @@ | ||
| 1 | +(* Sort: slices in many orders and of every length up to 40 come out | |
| 2 | + in order, holding what they held; and a sort by a record's field. *) | |
| 3 | +module Sorted; | |
| 4 | +import Fmt, Rt, Ints := Sort(I64, below), ByAge := Sort(Person, younger); | |
| 5 | + | |
| 6 | +type Person = record name: []U8; age: I64; end; | |
| 7 | + | |
| 8 | +proc below(a, b: I64): BOOL; | |
| 9 | +begin | |
| 10 | + return a < b; | |
| 11 | +end; | |
| 12 | + | |
| 13 | +proc younger(a, b: Person): BOOL; | |
| 14 | +begin | |
| 15 | + return a.age < b.age; | |
| 16 | +end; | |
| 17 | + | |
| 18 | +proc main*; | |
| 19 | +var | |
| 20 | + a: [40]I64; count: [10]I64; n, i, kind, seed: I64; | |
| 21 | + people: [4]Person; | |
| 22 | +begin | |
| 23 | + seed := 7; | |
| 24 | + for n := 0 to 40 do | |
| 25 | + for kind := 0 to 3 do | |
| 26 | + for i := 0 to 9 do count[i] := 0; end; | |
| 27 | + for i := 0 to n - 1 do | |
| 28 | + seed := (seed * 1103515245 + 12345) & 7FFFFFFFH; | |
| 29 | + if kind = 0 then a[i] := seed mod 10; (* at random, with repeats *) | |
| 30 | + elsif kind = 1 then a[i] := i mod 10; (* rising *) | |
| 31 | + elsif kind = 2 then a[i] := 9 - i mod 10; (* falling *) | |
| 32 | + else a[i] := 5; (* all equal *) | |
| 33 | + end; | |
| 34 | + INC(count[a[i]]); | |
| 35 | + end; | |
| 36 | + Ints.sort(a[0..n]); | |
| 37 | + for i := 0 to n - 1 do | |
| 38 | + if (i > 0) and (a[i - 1] > a[i]) then Rt.stop("out of order"); end; | |
| 39 | + DEC(count[a[i]]); | |
| 40 | + end; | |
| 41 | + for i := 0 to 9 do | |
| 42 | + if count[i] # 0 then Rt.stop("not what it held"); end; | |
| 43 | + end; | |
| 44 | + end; | |
| 45 | + end; | |
| 46 | + people := [{name: "Ana", age: 41}, {name: "Bo", age: 7}, {name: "Cy", age: 90}, {name: "Di", age: 23}]; | |
| 47 | + ByAge.sort(people); | |
| 48 | + for i := 0 to 3 do Fmt.print("{} {}\n", [Fmt.str(people[i].name), Fmt.int(people[i].age)]); end; | |
| 49 | +end; | |
| 50 | + | |
| 51 | +end Sorted. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +eq ne lit arr buf 0 5 2 | |
| 2 | +6 100 0 | |
| 3 | +threeone | |
| 4 | +é☺A |
| @@ -0,0 +1,39 @@ | ||
| 1 | +module Strings; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +const greeting = "hello"; | |
| 5 | + | |
| 6 | +var buf: [8]U8; | |
| 7 | + | |
| 8 | +proc count(xs: []I64): I64; | |
| 9 | +var i, s: I64; | |
| 10 | +begin | |
| 11 | + s := 0; | |
| 12 | + for i := 0 to LEN(xs) - 1 do s := s + xs[i]; end; | |
| 13 | + return s; | |
| 14 | +end; | |
| 15 | + | |
| 16 | +proc main*; | |
| 17 | +var a: []U8; b: [5]U8; c: [3]I64; d: [][]U8; | |
| 18 | +begin | |
| 19 | + a := "hello"; | |
| 20 | + if a = greeting then Out.str("eq "); end; | |
| 21 | + if a # "help" then Out.str("ne "); end; | |
| 22 | + if "abc" = "abc" then Out.str("lit "); end; | |
| 23 | + b := "hello"; | |
| 24 | + if b = a then Out.str("arr "); end; | |
| 25 | + buf := "hi"; | |
| 26 | + if buf[0..2] = "hi" then Out.str("buf "); end; | |
| 27 | + Out.int(I64(buf[5])); Out.str(" "); | |
| 28 | + Out.int(LEN(greeting)); Out.str(" "); | |
| 29 | + Out.int(LEN(a[1..3])); Out.ln; | |
| 30 | + c := [1, 2, 3]; | |
| 31 | + Out.int(count(c)); Out.str(" "); | |
| 32 | + Out.int(count([10, 20, 30, 40])); Out.str(" "); | |
| 33 | + Out.int(count([])); Out.ln; | |
| 34 | + d := ["one", "two", "three"]; | |
| 35 | + Out.str(d[2]); Out.str(d[0]); Out.ln; | |
| 36 | + Out.str("é\u{263A}\x41\n"); | |
| 37 | +end; | |
| 38 | + | |
| 39 | +end Strings. |
| @@ -0,0 +1,14 @@ | ||
| 1 | +module First; | |
| 2 | +import Out; | |
| 3 | + | |
| 4 | +var count*: I64; | |
| 5 | + | |
| 6 | +proc main*; | |
| 7 | +begin | |
| 8 | + Out.str("First.main must not run"); | |
| 9 | +end; | |
| 10 | + | |
| 11 | +begin | |
| 12 | + count := 1; | |
| 13 | + Out.str("First "); | |
| 14 | +end First. |
| @@ -0,0 +1,10 @@ | ||
| 1 | +(* A generic module with a body, which runs once for each instance *) | |
| 2 | +module Loud(T); | |
| 3 | +import Out; | |
| 4 | + | |
| 5 | +var size*: I64; | |
| 6 | + | |
| 7 | +begin | |
| 8 | + size := SIZE(T); | |
| 9 | + Out.str("an instance of Loud, of size "); Out.int(size); Out.ln; | |
| 10 | +end Loud. |
| @@ -0,0 +1,11 @@ | ||
| 1 | +module Second; | |
| 2 | +import Out, First; | |
| 3 | + | |
| 4 | +var count*: I64; | |
| 5 | + | |
| 6 | +begin | |
| 7 | + count := First.count + 1; | |
| 8 | + Out.str("Second "); | |
| 9 | + if count = 2 then return; end; | |
| 10 | + Out.str("not reached"); | |
| 11 | +end Second. |
| @@ -0,0 +1,13 @@ | ||
| 1 | +module Stack; | |
| 2 | +import Ints := List(I64), Heap; | |
| 3 | + | |
| 4 | +var s*: Ints.List; | |
| 5 | + | |
| 6 | +proc top*(): I64; | |
| 7 | +begin | |
| 8 | + return s.head^.val; | |
| 9 | +end; | |
| 10 | + | |
| 11 | +begin | |
| 12 | + Ints.init(ADR(s), Heap.heap); | |
| 13 | +end Stack. |
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | #!/bin/sh |
| 2 | -# Compiles and runs every example and test, and compares what each | |
| 3 | -# prints, and its exit status, with what is expected: | |
| 2 | +# Runs the conformance suite, conform/check.sh, with this compiler's | |
| 3 | +# messages for it in test/msg; then compiles and runs every example | |
| 4 | +# and this compiler's own tests, and compares what each prints, and its | |
| 5 | +# exit status, with what is expected: | |
| 4 | 6 | # X.raz the program |
| 5 | 7 | # X.expect its standard output |
| 6 | 8 | # X.args its arguments, one per line (optional) |
| @@ -22,6 +24,11 @@ | ||
| 22 | 24 | pass=0 |
| 23 | 25 | fail=0 |
| 24 | 26 | |
| 27 | +conform/check.sh $raz test/msg > $out/conform.out | |
| 28 | +grep -v '^[0-9]* passed' $out/conform.out | |
| 29 | +set -- $(tail -1 $out/conform.out) | |
| 30 | +pass=$1; fail=$3 | |
| 31 | + | |
| 25 | 32 | run() { # run dir name |
| 26 | 33 | dir=$1; name=$2 |
| 27 | 34 | flags= |
| @@ -69,7 +76,7 @@ | ||
| 69 | 76 | if cmp -s $out/run.out ${f%.raz}.expect && [ $status = $want ]; then pass=$((pass + 1)) |
| 70 | 77 | else echo "FAIL raz run $f: status $status, not $want, or output differs"; fail=$((fail + 1)); fi |
| 71 | 78 | } |
| 72 | -runs test/run/Args.raz 4 one 'two words' é | |
| 79 | +runs conform/run/Args.raz 4 one 'two words' é | |
| 73 | 80 | runs test/libc/Through.raz 2 |
| 74 | 81 | for f in test/err/*.raz; do |
| 75 | 82 | name=$(basename $f .raz) |
| @@ -163,7 +170,7 @@ | ||
| 163 | 170 | else pass=$((pass + 1)); fi |
| 164 | 171 | } |
| 165 | 172 | if ./raz -Werror -o $out/Mutate tools/Mutate.raz 2>$out/Mutate.cerr; then |
| 166 | - for f in examples/*.raz test/run/*.raz lib/Opt.raz; do | |
| 173 | + for f in examples/*.raz conform/run/*.raz test/run/*.raz lib/Opt.raz; do | |
| 167 | 174 | $raz -I $(dirname $f)/mods -o $out/mutant $f 2>/dev/null || continue |
| 168 | 175 | for seed in ${FUZZ_SEEDS:-1 2 3}; do fuzz $f $seed; done |
| 169 | 176 | done |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/AmpBools.raz:5:10: error: "&" needs integers, found BOOL | |
| 2 | - 5 | b := b & true; | |
| 3 | - | ^ | |
| 4 | -help: BOOLs take and | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AmpBools; | |
| 2 | -proc main*; | |
| 3 | -var b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - b := b & true; | |
| 6 | -end; | |
| 7 | -end AmpBools. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/ArrayEqReal.raz:6:8: error: can't compare arrays of reals with "=" | |
| 2 | - 6 | if a = b then end; | |
| 3 | - | ^^^^^ | |
| 4 | -help: -0.0 = 0.0 and a NaN equals nothing, though their bytes say otherwise: write a loop | |
| 5 | -raz: 1 error |
| @@ -1,9 +0,0 @@ | ||
| 1 | -module ArrayEqReal; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var a, b: [2]F64; | |
| 5 | -begin | |
| 6 | - if a = b then end; | |
| 7 | -end; | |
| 8 | - | |
| 9 | -end ArrayEqReal. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/ArrayEqRecord.raz:6:8: error: can't compare arrays of record with "=" | |
| 2 | - 6 | if a = b then end; | |
| 3 | - | ^^^^^ | |
| 4 | -help: write a loop | |
| 5 | -raz: 1 error |
| @@ -1,9 +0,0 @@ | ||
| 1 | -module ArrayEqRecord; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var a, b: [2]record x: I64; end; | |
| 5 | -begin | |
| 6 | - if a = b then end; | |
| 7 | -end; | |
| 8 | - | |
| 9 | -end ArrayEqRecord. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ArrayEqTypes.raz:6:8: error: can't compare an array of I64 with one of I32 | |
| 2 | - 6 | if a # b then end; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,9 +0,0 @@ | ||
| 1 | -module ArrayEqTypes; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var a: [2]I64; b: [2]I32; | |
| 5 | -begin | |
| 6 | - if a # b then end; | |
| 7 | -end; | |
| 8 | - | |
| 9 | -end ArrayEqTypes. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/Assign.raz:5:10: error: can't use I32 as I64 | |
| 2 | - 5 | a := b; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module Assign; | |
| 2 | -proc main*; | |
| 3 | -var a: I64; b: I32; | |
| 4 | -begin | |
| 5 | - a := b; | |
| 6 | -end; | |
| 7 | -end Assign. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/AtAnd.raz:5:16: error: "and" needs BOOLs, found I64 | |
| 2 | - 5 | b := b and (x + 1); | |
| 3 | - | ^^^^^^^ | |
| 4 | -help: the bits of integers take & | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtAnd; | |
| 2 | -proc main*; | |
| 3 | -var b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - b := b and (x + 1); | |
| 6 | -end; | |
| 7 | -end AtAnd. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtArgType.raz:7:8: error: can't use BOOL as I64 | |
| 2 | - 7 | Id(b); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,9 +0,0 @@ | ||
| 1 | -module AtArgType; | |
| 2 | -proc Id(a: I64): I64; | |
| 3 | -begin return a; end; | |
| 4 | -proc main*; | |
| 5 | -var b: BOOL; | |
| 6 | -begin | |
| 7 | - Id(b); | |
| 8 | -end; | |
| 9 | -end AtArgType. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtBinary.raz:5:10: error: I64 and BOOL are different types | |
| 2 | - 5 | x := (x + 2) * b; | |
| 3 | - | ^^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtBinary; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; b: BOOL; | |
| 4 | -begin | |
| 5 | - x := (x + 2) * b; | |
| 6 | -end; | |
| 7 | -end AtBinary. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtCall.raz:5:10: error: expected a procedure, found I64 | |
| 2 | - 5 | x := x(1); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtCall; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; | |
| 4 | -begin | |
| 5 | - x := x(1); | |
| 6 | -end; | |
| 7 | -end AtCall. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtCondition.raz:5:8: error: a condition is a BOOL, found I64 | |
| 2 | - 5 | if x + 1 then end; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtCondition; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; | |
| 4 | -begin | |
| 5 | - if x + 1 then end; | |
| 6 | -end; | |
| 7 | -end AtCondition. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtConstFit.raz:5:10: error: 3000000005 doesn't fit I32 | |
| 2 | - 5 | x := 5 + 3000000000; | |
| 3 | - | ^^^^^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtConstFit; | |
| 2 | -proc main*; | |
| 3 | -var x: I32; | |
| 4 | -begin | |
| 5 | - x := 5 + 3000000000; | |
| 6 | -end; | |
| 7 | -end AtConstFit. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtConvert.raz:5:14: error: can't convert BOOL to I64 | |
| 2 | - 5 | x := I64(b); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtConvert; | |
| 2 | -proc main*; | |
| 3 | -var b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - x := I64(b); | |
| 6 | -end; | |
| 7 | -end AtConvert. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtDeref.raz:5:10: error: expected a pointer, found I64 | |
| 2 | - 5 | y := x^; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtDeref; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - y := x^; | |
| 6 | -end; | |
| 7 | -end AtDeref. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtDivZero.raz:5:10: error: division by zero | |
| 2 | - 5 | x := 7 div (3 - 3); | |
| 3 | - | ^^^^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtDivZero; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; | |
| 4 | -begin | |
| 5 | - x := 7 div (3 - 3); | |
| 6 | -end; | |
| 7 | -end AtDivZero. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtIndex.raz:5:12: error: an index is an integer, found BOOL | |
| 2 | - 5 | x := a[b]; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtIndex; | |
| 2 | -proc main*; | |
| 3 | -var a: [4]I64; b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - x := a[b]; | |
| 6 | -end; | |
| 7 | -end AtIndex. |
| @@ -1,7 +0,0 @@ | ||
| 1 | -test/err/AtMany.raz:7:16: error: too many arguments: Id takes 1 | |
| 2 | - 7 | x := Id(1, 2 * 3); | |
| 3 | - | ^^^^^ | |
| 4 | -test/err/AtMany.raz:2:6: note: the signature is here | |
| 5 | - 2 | proc Id(a: I64): I64; | |
| 6 | - | ^^ | |
| 7 | -raz: 1 error |
| @@ -1,9 +0,0 @@ | ||
| 1 | -module AtMany; | |
| 2 | -proc Id(a: I64): I64; | |
| 3 | -begin return a; end; | |
| 4 | -proc main*; | |
| 5 | -var x: I64; | |
| 6 | -begin | |
| 7 | - x := Id(1, 2 * 3); | |
| 8 | -end; | |
| 9 | -end AtMany. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtMatch.raz:5:11: error: match needs a variant or an enumeration, found I64 | |
| 2 | - 5 | match x + 1 do end; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtMatch; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; | |
| 4 | -begin | |
| 5 | - match x + 1 do end; | |
| 6 | -end; | |
| 7 | -end AtMatch. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtNegate.raz:5:10: error: can't negate BOOL | |
| 2 | - 5 | x := -b; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtNegate; | |
| 2 | -proc main*; | |
| 3 | -var b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - x := -b; | |
| 6 | -end; | |
| 7 | -end AtNegate. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtNot.raz:5:14: error: "not" needs a BOOL, found []U8 | |
| 2 | - 5 | b := not s; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtNot; | |
| 2 | -proc main*; | |
| 3 | -var s: []U8; b: BOOL; | |
| 4 | -begin | |
| 5 | - b := not s; | |
| 6 | -end; | |
| 7 | -end AtNot. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtNotValue.raz:5:10: error: I64 is a type, not a value | |
| 2 | - 5 | x := I64 + 1; | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtNotValue; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; | |
| 4 | -begin | |
| 5 | - x := I64 + 1; | |
| 6 | -end; | |
| 7 | -end AtNotValue. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPAdr.raz:5:14: error: ADR needs a variable | |
| 2 | - 5 | p := ADR(1); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPAdr; | |
| 2 | -proc main*; | |
| 3 | -var p: ^I64; | |
| 4 | -begin | |
| 5 | - p := ADR(1); | |
| 6 | -end; | |
| 7 | -end AtPAdr. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPArrayLen.raz:2:9: error: an array's length is from 1 to 2^40, found 0 | |
| 2 | - 2 | var a: [0]I64; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module AtPArrayLen; | |
| 2 | -var a: [0]I64; | |
| 3 | -proc main*; | |
| 4 | -begin | |
| 5 | -end; | |
| 6 | -end AtPArrayLen. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPCantAssign.raz:7:8: error: can't assign to k | |
| 2 | - 7 | a, k := two(); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,9 +0,0 @@ | ||
| 1 | -module AtPCantAssign; | |
| 2 | -const k = 1; | |
| 3 | -proc two: (I64, I64); begin return 1, 2; end; | |
| 4 | -proc main*; | |
| 5 | -var a: I64; | |
| 6 | -begin | |
| 7 | - a, k := two(); | |
| 8 | -end; | |
| 9 | -end AtPCantAssign. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPChar.raz:5:12: error: unexpected character "?" | |
| 2 | - 5 | a := 1 ? 2; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPChar; | |
| 2 | -proc main*; | |
| 3 | -var a: I64; | |
| 4 | -begin | |
| 5 | - a := 1 ? 2; | |
| 6 | -end; | |
| 7 | -end AtPChar. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPComment.raz:5:1: error: comment not closed | |
| 2 | - 5 | (* never closed | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module AtPComment; | |
| 2 | -proc main*; | |
| 3 | -begin | |
| 4 | -end; | |
| 5 | -(* never closed | |
| 6 | -end AtPComment. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPConstExpr.raz:4:9: error: expected a constant | |
| 2 | - 4 | var a: [n]I64; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPConstExpr; | |
| 2 | -proc main*; | |
| 3 | -var n: I64; | |
| 4 | -var a: [n]I64; | |
| 5 | -begin | |
| 6 | -end; | |
| 7 | -end AtPConstExpr. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPElems.raz:5:10: error: expected 3 elements, found 2 | |
| 2 | - 5 | a := [1, 2]; | |
| 3 | - | ^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPElems; | |
| 2 | -proc main*; | |
| 3 | -var a: [3]I64; | |
| 4 | -begin | |
| 5 | - a := [1, 2]; | |
| 6 | -end; | |
| 7 | -end AtPElems. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPEscape.raz:5:12: error: unknown escape \q | |
| 2 | - 5 | s := "a\q"; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPEscape; | |
| 2 | -proc main*; | |
| 3 | -var s: [8]U8; | |
| 4 | -begin | |
| 5 | - s := "a\q"; | |
| 6 | -end; | |
| 7 | -end AtPEscape. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPInc.raz:5:9: error: INC needs an integer variable | |
| 2 | - 5 | INC(a); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPInc; | |
| 2 | -proc main*; | |
| 3 | -var a: BOOL; | |
| 4 | -begin | |
| 5 | - INC(a); | |
| 6 | -end; | |
| 7 | -end AtPInc. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPLen.raz:5:14: error: LEN needs an array or a slice, found I64 | |
| 2 | - 5 | a := LEN(a); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPLen; | |
| 2 | -proc main*; | |
| 3 | -var a: I64; | |
| 4 | -begin | |
| 5 | - a := LEN(a); | |
| 6 | -end; | |
| 7 | -end AtPLen. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPNewVar.raz:5:9: error: NEW needs a pointer variable | |
| 2 | - 5 | NEW(a, a); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPNewVar; | |
| 2 | -proc main*; | |
| 3 | -var a: I64; | |
| 4 | -begin | |
| 5 | - NEW(a, a); | |
| 6 | -end; | |
| 7 | -end AtPNewVar. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPNoResult.raz:8:10: error: p returns nothing | |
| 2 | - 8 | a := p() + 1; | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,10 +0,0 @@ | ||
| 1 | -module AtPNoResult; | |
| 2 | -proc p; | |
| 3 | -begin | |
| 4 | -end; | |
| 5 | -proc main*; | |
| 6 | -var a: I64; | |
| 7 | -begin | |
| 8 | - a := p() + 1; | |
| 9 | -end; | |
| 10 | -end AtPNoResult. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPNotRecord.raz:5:10: error: expected a record, found I64 | |
| 2 | - 5 | a := a.f; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPNotRecord; | |
| 2 | -proc main*; | |
| 3 | -var a: I64; | |
| 4 | -begin | |
| 5 | - a := a.f; | |
| 6 | -end; | |
| 7 | -end AtPNotRecord. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPNotStmt.raz:5:5: error: a isn't a statement | |
| 2 | - 5 | a; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPNotStmt; | |
| 2 | -proc main*; | |
| 3 | -var a: I64; | |
| 4 | -begin | |
| 5 | - a; | |
| 6 | -end; | |
| 7 | -end AtPNotStmt. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPSetLit.raz:6:14: error: 1 isn't a name of C | |
| 2 | - 6 | s := {r, 1}; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module AtPSetLit; | |
| 2 | -type C = (r, g, b); | |
| 3 | -proc main*; | |
| 4 | -var s: set of C; | |
| 5 | -begin | |
| 6 | - s := {r, 1}; | |
| 7 | -end; | |
| 8 | -end AtPSetLit. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPStep.raz:5:24: error: the step can't be zero | |
| 2 | - 5 | for i := 1 to 5 by 1 - 1 do end; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPStep; | |
| 2 | -proc main*; | |
| 3 | -var i: I64; | |
| 4 | -begin | |
| 5 | - for i := 1 to 5 by 1 - 1 do end; | |
| 6 | -end; | |
| 7 | -end AtPStep. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtPtrMinus.raz:5:10: error: ^I64 and ^I32 are different types | |
| 2 | - 5 | x := p - q; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtPtrMinus; | |
| 2 | -proc main*; | |
| 3 | -var p: ^I64; q: ^I32; x: I64; | |
| 4 | -begin | |
| 5 | - x := p - q; | |
| 6 | -end; | |
| 7 | -end AtPtrMinus. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtReturn.raz:4:12: error: this procedure returns nothing | |
| 2 | - 4 | return 1 + 2; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module AtReturn; | |
| 2 | -proc main*; | |
| 3 | -begin | |
| 4 | - return 1 + 2; | |
| 5 | -end; | |
| 6 | -end AtReturn. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtSliceHi.raz:5:15: error: an index is an integer, found BOOL | |
| 2 | - 5 | s := a[0..b]; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtSliceHi; | |
| 2 | -proc main*; | |
| 3 | -var a: [4]I64; b: BOOL; s: []I64; | |
| 4 | -begin | |
| 5 | - s := a[0..b]; | |
| 6 | -end; | |
| 7 | -end AtSliceHi. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtSliceLo.raz:5:12: error: an index is an integer, found BOOL | |
| 2 | - 5 | s := a[b..2]; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtSliceLo; | |
| 2 | -proc main*; | |
| 3 | -var a: [4]I64; b: BOOL; s: []I64; | |
| 4 | -begin | |
| 5 | - s := a[b..2]; | |
| 6 | -end; | |
| 7 | -end AtSliceLo. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtStrCmp.raz:5:8: error: can't compare an array with I64 | |
| 2 | - 5 | if s = x + 1 then end; | |
| 3 | - | ^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module AtStrCmp; | |
| 2 | -proc main*; | |
| 3 | -var s: []U8; x: I64; | |
| 4 | -begin | |
| 5 | - if s = x + 1 then end; | |
| 6 | -end; | |
| 7 | -end AtStrCmp. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/AtVarArg.raz:7:9: error: a var parameter needs a variable | |
| 2 | - 7 | Inc(1 + 2); | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,9 +0,0 @@ | ||
| 1 | -module AtVarArg; | |
| 2 | -proc Inc(var a: I64); | |
| 3 | -begin a := a + 1; end; | |
| 4 | -proc main*; | |
| 5 | -var x: I64; | |
| 6 | -begin | |
| 7 | - Inc(1 + 2); | |
| 8 | -end; | |
| 9 | -end AtVarArg. |
| @@ -1,7 +0,0 @@ | ||
| 1 | -test/err/BadProc.raz:2:33: error: cmp doesn't have the signature of hash | |
| 2 | - 2 | import Str, M := Map([]U8, I64, Str.cmp, Str.eq); | |
| 3 | - | ^^^^^^^ | |
| 4 | -lib/Map.raz:4:18: note: the signature is here | |
| 5 | - 4 | module Map(K, V; hash: proc(k: K): U64; eq: proc(a, b: K): BOOL); | |
| 6 | - | ^^^^ | |
| 7 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module BadProc; | |
| 2 | -import Str, M := Map([]U8, I64, Str.cmp, Str.eq); | |
| 3 | - | |
| 4 | -var m: M.Map; | |
| 5 | - | |
| 6 | -end BadProc. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/BarBools.raz:5:10: error: "|" needs integers, found BOOL | |
| 2 | - 5 | b := b | true; | |
| 3 | - | ^ | |
| 4 | -help: BOOLs take or | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module BarBools; | |
| 2 | -proc main*; | |
| 3 | -var b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - b := b | true; | |
| 6 | -end; | |
| 7 | -end BarBools. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/BigI64.raz:5:10: error: can't use U64 as I64 | |
| 2 | - 5 | i := 0FFFFFFFFFFFFFFFFH; | |
| 3 | - | ^^^^^^^^^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module BigI64; | |
| 2 | -proc main*; | |
| 3 | -var i: I64; | |
| 4 | -begin | |
| 5 | - i := 0FFFFFFFFFFFFFFFFH; | |
| 6 | -end; | |
| 7 | -end BigI64. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/Break.raz:4:5: error: break outside a loop | |
| 2 | - 4 | break; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module Break; | |
| 2 | -proc main*; | |
| 3 | -begin | |
| 4 | - break; | |
| 5 | -end; | |
| 6 | -end Break. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/mods/CycleB.raz:2:8: error: Cycle imports itself | |
| 2 | - 2 | import Cycle; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module Cycle; | |
| 2 | -import CycleB; | |
| 3 | -end Cycle. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module DeclArrayUnknown; | |
| 2 | -proc main*; | |
| 3 | -begin | |
| 4 | - if [1] = [1] then end; | |
| 5 | -end; | |
| 6 | -end DeclArrayUnknown. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclAtomicPtr.raz:5:15: error: expected a pointer, found I64 | |
| 2 | - 5 | n := XADD(n, 1); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module DeclAtomicPtr; | |
| 2 | -proc main*; | |
| 3 | -var n: I64; | |
| 4 | -begin | |
| 5 | - n := XADD(n, 1); | |
| 6 | -end; | |
| 7 | -end DeclAtomicPtr. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclEnumNames.raz:2:10: error: an enumeration has at most 256 names | |
| 2 | - 2 | type E = ( | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclIntConst.raz:3:9: error: expected an integer constant, found 1.5 | |
| 2 | - 3 | var a: [1.5]I64; | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module DeclIntConst; | |
| 2 | -proc main*; | |
| 3 | -var a: [1.5]I64; | |
| 4 | -begin | |
| 5 | -end; | |
| 6 | -end DeclIntConst. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclLitNoField.raz:6:11: error: R has no field b | |
| 2 | - 6 | r := {b: 1}; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclNeedsFields.raz:9:10: error: circle needs its fields | |
| 2 | - 9 | s := circle; | |
| 3 | - | ^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,11 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module DeclNewAllocator; | |
| 2 | -proc main*; | |
| 3 | -var p, q: ^I64; | |
| 4 | -begin | |
| 5 | - NEW(p, q); | |
| 6 | -end; | |
| 7 | -end DeclNewAllocator. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclNoField.raz:6:7: error: R has no field b | |
| 2 | - 6 | r.b := 1; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,10 +0,0 @@ | ||
| 1 | -test/err/mods/DeclHidden.raz:3:7: warning: constant hidden is never used | |
| 2 | - 3 | const hidden = 2; | |
| 3 | - | ^^^^^^ | |
| 4 | -test/err/DeclNotExported.raz:6:21: error: hidden isn't exported by DeclHidden | |
| 5 | - 6 | n := DeclHidden.hidden; | |
| 6 | - | ^^^^^^ | |
| 7 | -test/err/mods/DeclHidden.raz:3:7: note: hidden is declared here, without a * | |
| 8 | - 3 | const hidden = 2; | |
| 9 | - | ^^^^^^ | |
| 10 | -raz: 1 error, 1 warning |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module DeclNotExported; | |
| 2 | -import DeclHidden; | |
| 3 | -proc main*; | |
| 4 | -var n: I64; | |
| 5 | -begin | |
| 6 | - n := DeclHidden.hidden; | |
| 7 | -end; | |
| 8 | -end DeclNotExported. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclNotType.raz:4:8: error: n isn't a type | |
| 2 | - 4 | var a: n; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module DeclNotType; | |
| 2 | -proc main*; | |
| 3 | -var n: I64; | |
| 4 | -var a: n; | |
| 5 | -begin | |
| 6 | -end; | |
| 7 | -end DeclNotType. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclSetLitType.raz:6:10: error: expected a set type, found I64 | |
| 2 | - 6 | n := {r}; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclSetNames.raz:6:16: error: a set holds names of an enumeration, found 1 | |
| 2 | - 6 | s := {} + {1}; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module DeclSetType; | |
| 2 | -proc main*; | |
| 3 | -var s: set of I64; | |
| 4 | -begin | |
| 5 | -end; | |
| 6 | -end DeclSetType. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeclSetUnknown.raz:4:8: error: {} needs a known set type | |
| 2 | - 4 | if {} = {} then end; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module DeclSetUnknown; | |
| 2 | -proc main*; | |
| 3 | -begin | |
| 4 | - if {} = {} then end; | |
| 5 | -end; | |
| 6 | -end DeclSetUnknown. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeferBreak.raz:5:15: error: break outside a loop | |
| 2 | - 5 | defer break; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module DeferBreak; | |
| 2 | -proc f; | |
| 3 | -begin | |
| 4 | - while true do | |
| 5 | - defer break; | |
| 6 | - end; | |
| 7 | -end; | |
| 8 | -end DeferBreak. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeferDefer.raz:4:11: error: defer can't be deferred | |
| 2 | - 4 | defer defer f; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module DeferDefer; | |
| 2 | -proc f; | |
| 3 | -begin | |
| 4 | - defer defer f; | |
| 5 | -end; | |
| 6 | -end DeferDefer. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/DeferReturn.raz:4:11: error: return can't leave a deferred statement | |
| 2 | - 4 | defer return 1; | |
| 3 | - | ^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module DeferReturn; | |
| 2 | -proc f: I64; | |
| 3 | -begin | |
| 4 | - defer return 1; | |
| 5 | - return 0; | |
| 6 | -end; | |
| 7 | -end DeferReturn. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ErrOrder.raz:5:8: error: "<" doesn't apply to ERROR | |
| 2 | - 5 | if A < B then end; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ErrOrder; | |
| 2 | -const A: ERROR = "a"; B: ERROR = "b"; | |
| 3 | -proc main*; | |
| 4 | -begin | |
| 5 | - if A < B then end; | |
| 6 | -end; | |
| 7 | -end ErrOrder. |
| @@ -1,7 +0,0 @@ | ||
| 1 | -test/err/FirstUseLate.raz:2:18: error: Later isn't declared | |
| 2 | - 2 | import L := List(Later); | |
| 3 | - | ^^^^^ | |
| 4 | -test/err/FirstUseLate.raz:4:8: note: the instance is made here, where it is first used | |
| 5 | - 4 | var l: L.List; (* made here, before Later is declared *) | |
| 6 | - | ^ | |
| 7 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module FirstUseLate; | |
| 2 | -import L := List(Later); | |
| 3 | - | |
| 4 | -var l: L.List; (* made here, before Later is declared *) | |
| 5 | - | |
| 6 | -type Later = I64; | |
| 7 | - | |
| 8 | -end FirstUseLate. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenBoolOp.raz:6:10: error: "+" doesn't apply to BOOL | |
| 2 | - 6 | b := b + b; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenBoolOp; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var b: BOOL; | |
| 5 | -begin | |
| 6 | - b := b + b; | |
| 7 | -end; | |
| 8 | -end GenBoolOp. |
| @@ -1,10 +0,0 @@ | ||
| 1 | -test/err/GenConstOverflow.raz:5:12: error: the constant is too big for I64 | |
| 2 | - 5 | Over = Big + 1; | |
| 3 | - | ^^^^^^^ | |
| 4 | -test/err/GenConstOverflow.raz:6:13: error: the constant is too big for I64 | |
| 5 | - 6 | Twice = 4611686018427387904 * 2; | |
| 6 | - | ^^^^^^^^^^^^^^^^^^^^^^^ | |
| 7 | -test/err/GenConstOverflow.raz:7:13: error: the constant is too big for I64 | |
| 8 | - 7 | Under = -Big - 2; | |
| 9 | - | ^^^^^^^^ | |
| 10 | -raz: 3 errors |
| @@ -1,14 +0,0 @@ | ||
| 1 | -module GenConstOverflow; | |
| 2 | -(* An untyped constant doesn't wrap *) | |
| 3 | -const | |
| 4 | - Big = 9223372036854775807; | |
| 5 | - Over = Big + 1; | |
| 6 | - Twice = 4611686018427387904 * 2; | |
| 7 | - Under = -Big - 2; | |
| 8 | - Fine = U8(250) + 10; | |
| 9 | - | |
| 10 | -proc main*; | |
| 11 | -begin | |
| 12 | -end; | |
| 13 | - | |
| 14 | -end GenConstOverflow. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenConvertString.raz:6:14: error: can't convert a string | |
| 2 | - 6 | x := I64("a"); | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenConvertString; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x: I64; | |
| 5 | -begin | |
| 6 | - x := I64("a"); | |
| 7 | -end; | |
| 8 | -end GenConvertString. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenConvertType; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x: I64; | |
| 5 | -begin | |
| 6 | - x := I64(I64); | |
| 7 | -end; | |
| 8 | -end GenConvertType. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenDivOverflow.raz:6:10: error: division overflows | |
| 2 | - 6 | x := (-9223372036854775807 - 1) div (0 - 1); | |
| 3 | - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,9 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenEnumOp.raz:6:10: error: "+" doesn't apply to C | |
| 2 | - 6 | c := c + c; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module GenErrorString; | |
| 2 | -const E: ERROR = 1; | |
| 3 | -proc main*; | |
| 4 | -begin | |
| 5 | - | |
| 6 | -end; | |
| 7 | -end GenErrorString. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/GenIntReal.raz:6:10: error: I64 and F64 are different types | |
| 2 | - 6 | y := x + y; | |
| 3 | - | ^^^^^ | |
| 4 | -help: convert one to the other's type, as in I64(y) | |
| 5 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenIntReal; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x: I64; y: F64; | |
| 5 | -begin | |
| 6 | - y := x + y; | |
| 7 | -end; | |
| 8 | -end GenIntReal. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/GenIntTypes.raz:6:10: error: I32 and I64 are different types | |
| 2 | - 6 | b := a + b; | |
| 3 | - | ^^^^^ | |
| 4 | -help: convert one to the other's type, as in I32(b) | |
| 5 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenIntTypes; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var a: I32; b: I64; | |
| 5 | -begin | |
| 6 | - b := a + b; | |
| 7 | -end; | |
| 8 | -end GenIntTypes. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenNotIndexable; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x: I64; | |
| 5 | -begin | |
| 6 | - x := x[0]; | |
| 7 | -end; | |
| 8 | -end GenNotIndexable. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenNotVariable.raz:5:7: error: a var parameter needs a variable | |
| 2 | - 5 | P(1); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module GenNotVariable; | |
| 2 | -proc P(var a: I64); begin end; | |
| 3 | -proc main*; | |
| 4 | -begin | |
| 5 | - P(1); | |
| 6 | -end; | |
| 7 | -end GenNotVariable. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenPtrOp.raz:6:10: error: "+" doesn't apply to ^I64 | |
| 2 | - 6 | b := p + p; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenPtrOp; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var p: ^I64; b: BOOL; | |
| 5 | -begin | |
| 6 | - b := p + p; | |
| 7 | -end; | |
| 8 | -end GenPtrOp. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenRealOp; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x: F64; | |
| 5 | -begin | |
| 6 | - x := x mod 2.0; | |
| 7 | -end; | |
| 8 | -end GenRealOp. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module GenReturnNone; | |
| 2 | -proc P(): I64; begin return; end; | |
| 3 | -proc main*; | |
| 4 | -begin | |
| 5 | - P(); | |
| 6 | -end; | |
| 7 | -end GenReturnNone. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module GenReturnNothing; | |
| 2 | -proc P; begin return 1; end; | |
| 3 | -proc main*; | |
| 4 | -begin | |
| 5 | - P(); | |
| 6 | -end; | |
| 7 | -end GenReturnNothing. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenSetOp.raz:6:10: error: "<" doesn't apply to CS | |
| 2 | - 6 | b := a < a; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenSingleValue.raz:6:10: error: expected a single value, found R | |
| 2 | - 6 | x := r + 1; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/GenSlash.raz:6:10: error: "/" divides reals, not integers | |
| 2 | - 6 | x := 6 / 3; | |
| 3 | - | ^^^^^ | |
| 4 | -help: to divide integers, write 6 div 3 | |
| 5 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenSlash; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x: I64; | |
| 5 | -begin | |
| 6 | - x := 6 / 3; | |
| 7 | -end; | |
| 8 | -end GenSlash. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/GenSlashVar.raz:6:10: error: "/" divides reals, not integers | |
| 2 | - 6 | x := x / y; | |
| 3 | - | ^^^^^ | |
| 4 | -help: to divide integers, write x div y | |
| 5 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenSlashVar; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x, y: I64; | |
| 5 | -begin | |
| 6 | - x := x / y; | |
| 7 | -end; | |
| 8 | -end GenSlashVar. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenStringAs.raz:6:10: error: can't use a string as I64 | |
| 2 | - 6 | x := "a"; | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenStringAs; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x: I64; | |
| 5 | -begin | |
| 6 | - x := "a"; | |
| 7 | -end; | |
| 8 | -end GenStringAs. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module GenStringOperand; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x: I64; | |
| 5 | -begin | |
| 6 | - x := "a" + 1; | |
| 7 | -end; | |
| 8 | -end GenStringOperand. |
| @@ -1,7 +0,0 @@ | ||
| 1 | -test/err/GenTooFew.raz:6:14: error: too few arguments: Id takes 1 | |
| 2 | - 6 | x := Id(); | |
| 3 | - | ^ | |
| 4 | -test/err/GenTooFew.raz:2:6: note: the signature is here | |
| 5 | - 2 | proc Id(a: I64): I64; begin return a; end; | |
| 6 | - | ^^ | |
| 7 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenTooFewValue.raz:6:8: error: too few arguments | |
| 2 | - 6 | f(); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenTooManyValue.raz:6:10: error: too many arguments | |
| 2 | - 6 | f(1, 2); | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/GenVolCopy.raz:6:10: error: can't copy through a volatile pointer | |
| 2 | - 6 | r := p^; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 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 +0,0 @@ | ||
| 1 | -test/err/Match.raz:9:5: error: no arm for c | |
| 2 | - 9 | end; | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,11 +0,0 @@ | ||
| 1 | -module Match; | |
| 2 | -type S = variant a; b; c; end; | |
| 3 | -proc main*; | |
| 4 | -var s: S; | |
| 5 | -begin | |
| 6 | - match s of | |
| 7 | - | a: s := b; | |
| 8 | - | b: | |
| 9 | - end; | |
| 10 | -end; | |
| 11 | -end Match. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/Mixed.raz:6:10: error: F32 and F64 are different types | |
| 2 | - 6 | y := x + y; | |
| 3 | - | ^^^^^ | |
| 4 | -help: convert one to the other's type, as in F32(y) | |
| 5 | -raz: 1 error |
| @@ -1,9 +0,0 @@ | ||
| 1 | -module Mixed; | |
| 2 | - | |
| 3 | -proc main*; | |
| 4 | -var x: F32; y: F64; | |
| 5 | -begin | |
| 6 | - y := x + y; | |
| 7 | -end; | |
| 8 | - | |
| 9 | -end Mixed. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/NegU64.raz:5:10: error: -1 doesn't fit U64 | |
| 2 | - 5 | u := -1; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module NegU64; | |
| 2 | -proc main*; | |
| 3 | -var u: U64; | |
| 4 | -begin | |
| 5 | - u := -1; | |
| 6 | -end; | |
| 7 | -end NegU64. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/NoArgs.raz:2:8: error: List needs a type for T | |
| 2 | - 2 | import List; | |
| 3 | - | ^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module NoArgs; | |
| 2 | -import List; | |
| 3 | -end NoArgs. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/NotGeneric.raz:2:8: error: Str isn't generic | |
| 2 | - 2 | import S := Str(I64); | |
| 3 | - | ^^^^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,9 +0,0 @@ | ||
| 1 | -module NotGeneric; | |
| 2 | -import S := Str(I64); | |
| 3 | - | |
| 4 | -proc f(a, b: []U8): I64; | |
| 5 | -begin | |
| 6 | - return S.cmp(a, b); | |
| 7 | -end; | |
| 8 | - | |
| 9 | -end NotGeneric. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/NotInt.raz:5:14: error: "not" needs a BOOL, found I64 | |
| 2 | - 5 | x := not x; | |
| 3 | - | ^ | |
| 4 | -help: the bits of an integer flip with ~ | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module NotInt; | |
| 2 | -proc main*; | |
| 3 | -var b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - x := not x; | |
| 6 | -end; | |
| 7 | -end NotInt. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/NoteBuiltin.raz:5:10: error: len isn't declared | |
| 2 | - 5 | x := len(y); | |
| 3 | - | ^^^ | |
| 4 | -help: did you mean LEN? | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module NoteBuiltin; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - x := len(y); | |
| 6 | -end; | |
| 7 | -end NoteBuiltin. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/NoteExport.raz:6:9: error: Int isn't exported by Out | |
| 2 | - 6 | Out.Int(x); | |
| 3 | - | ^^^ | |
| 4 | -help: did you mean int? | |
| 5 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module NoteExport; | |
| 2 | -import Out; | |
| 3 | -proc main*; | |
| 4 | -var x, y: I64; | |
| 5 | -begin | |
| 6 | - Out.Int(x); | |
| 7 | -end; | |
| 8 | -end NoteExport. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/NoteField.raz:6:7: error: P has no field cuont | |
| 2 | - 6 | p.cuont := 1; | |
| 3 | - | ^^^^^ | |
| 4 | -help: did you mean count? | |
| 5 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module NoteField; | |
| 2 | -type P = record count: I64; end; | |
| 3 | -proc main*; | |
| 4 | -var p: P; | |
| 5 | -begin | |
| 6 | - p.cuont := 1; | |
| 7 | -end; | |
| 8 | -end NoteField. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/NoteImport.raz:5:5: error: Fmt isn't declared | |
| 2 | - 5 | Fmt.print(x); | |
| 3 | - | ^^^ | |
| 4 | -help: Fmt is a module: import Fmt | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module NoteImport; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - Fmt.print(x); | |
| 6 | -end; | |
| 7 | -end NoteImport. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/NoteLocal.raz:6:5: error: cuont isn't declared | |
| 2 | - 6 | cuont := 1; | |
| 3 | - | ^^^^^ | |
| 4 | -help: did you mean count? | |
| 5 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module NoteLocal; | |
| 2 | -proc main*; | |
| 3 | -var x, y, count: I64; | |
| 4 | -begin | |
| 5 | - | |
| 6 | - cuont := 1; | |
| 7 | -end; | |
| 8 | -end NoteLocal. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/OrInts.raz:5:10: error: "or" needs BOOLs, found I64 | |
| 2 | - 5 | x := x or 1; | |
| 3 | - | ^ | |
| 4 | -help: the bits of integers take | | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module OrInts; | |
| 2 | -proc main*; | |
| 3 | -var b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - x := x or 1; | |
| 6 | -end; | |
| 7 | -end OrInts. |
| @@ -1,13 +0,0 @@ | ||
| 1 | -test/err/PackedAddress.raz:15:14: error: a field of a packed record has no address | |
| 2 | - 15 | p := ADR(h.len); | |
| 3 | - | ^^^^^ | |
| 4 | -test/err/PackedAddress.raz:16:9: error: a field of a packed record can't be a var parameter | |
| 5 | - 16 | put(h.len); | |
| 6 | - | ^^^^^ | |
| 7 | -test/err/PackedAddress.raz:17:10: error: can't make a slice of a field of a packed record | |
| 8 | - 17 | s := h.vals[0..1]; | |
| 9 | - | ^^^^^^ | |
| 10 | -test/err/PackedAddress.raz:19:5: error: a field of a packed record can't be volatile | |
| 11 | - 19 | q^.len := 2; | |
| 12 | - | ^^ | |
| 13 | -raz: 4 errors |
| @@ -1,24 +0,0 @@ | ||
| 1 | -module PackedAddress; | |
| 2 | -(* A field of a packed record may be misaligned: it has no address, | |
| 3 | - and no volatile access *) | |
| 4 | -type | |
| 5 | - Header = packed record kind: U8; len: U32; tag: U8; vals: [2]U16; end; | |
| 6 | - | |
| 7 | -proc put(var n: U32); | |
| 8 | -begin | |
| 9 | - n := 1; | |
| 10 | -end; | |
| 11 | - | |
| 12 | -proc main*; | |
| 13 | -var h: Header; p: ^U32; q: ^VOLATILE Header; k: ^U8; s: []U16; | |
| 14 | -begin | |
| 15 | - p := ADR(h.len); | |
| 16 | - put(h.len); | |
| 17 | - s := h.vals[0..1]; | |
| 18 | - q := ADR(h); | |
| 19 | - q^.len := 2; | |
| 20 | - k := ADR(h.tag); | |
| 21 | - h.len := 3; | |
| 22 | -end; | |
| 23 | - | |
| 24 | -end PackedAddress. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/PassOnTypes.raz:10:12: error: expected the results (BOOL, I64), found (I64, BOOL) | |
| 2 | - 10 | return two(n); | |
| 3 | - | ^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,19 +0,0 @@ | ||
| 1 | -module PassOnTypes; | |
| 2 | - | |
| 3 | -proc two(n: I64): (I64, BOOL); | |
| 4 | -begin | |
| 5 | - return n, n = 0; | |
| 6 | -end; | |
| 7 | - | |
| 8 | -proc swapped(n: I64): (BOOL, I64); | |
| 9 | -begin | |
| 10 | - return two(n); | |
| 11 | -end; | |
| 12 | - | |
| 13 | -proc main*; | |
| 14 | -var b: BOOL; i: I64; | |
| 15 | -begin | |
| 16 | - b, i := swapped(1); | |
| 17 | -end; | |
| 18 | - | |
| 19 | -end PassOnTypes. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/PtrArray.raz:6:5: error: a pointer to an array is indexed as p^[i] | |
| 2 | - 6 | p[1] := 0; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module PtrArray; | |
| 2 | -proc main*; | |
| 3 | -var a: [4]I64; p: ^[4]I64; | |
| 4 | -begin | |
| 5 | - p := ADR(a); | |
| 6 | - p[1] := 0; | |
| 7 | -end; | |
| 8 | -end PtrArray. |
| @@ -1,31 +0,0 @@ | ||
| 1 | -test/err/Recover.raz:6:27: error: Foo isn't declared | |
| 2 | - 6 | P = record a: I64; b: Foo; end; | |
| 3 | - | ^^^ | |
| 4 | -test/err/Recover.raz:9:8: error: Bar isn't declared | |
| 5 | - 9 | var g: Bar; | |
| 6 | - | ^^^ | |
| 7 | -test/err/Recover.raz:15:10: error: can't use I64 as BOOL | |
| 8 | - 15 | b := x; | |
| 9 | - | ^ | |
| 10 | -test/err/Recover.raz:16:10: error: y isn't declared | |
| 11 | - 16 | x := y + 1; | |
| 12 | - | ^ | |
| 13 | -test/err/Recover.raz:19:14: error: I64 and BOOL are different types | |
| 14 | - 19 | x := (x + 2) * b; | |
| 15 | - | ^^^^^^^^^^^ | |
| 16 | -test/err/Recover.raz:20:17: error: z isn't declared | |
| 17 | - 20 | Out.int(z); | |
| 18 | - | ^ | |
| 19 | -test/err/Recover.raz:22:12: error: I64 and BOOL are different types | |
| 20 | - 22 | return x + true; | |
| 21 | - | ^^^^^^^^ | |
| 22 | -test/err/Recover.raz:28:7: error: Q has no field c | |
| 23 | - 28 | q.c := 1; | |
| 24 | - | ^ | |
| 25 | -test/err/Recover.raz:30:18: error: expected ";", found "return" | |
| 26 | - 30 | Out.str("hi") | |
| 27 | - | ^ | |
| 28 | -test/err/Recover.raz:37:13: error: nope isn't declared | |
| 29 | - 37 | Out.int(nope(2)); | |
| 30 | - | ^^^^ | |
| 31 | -raz: 10 errors |
| @@ -1,40 +0,0 @@ | ||
| 1 | -module Recover; | |
| 2 | - | |
| 3 | -import Out; | |
| 4 | - | |
| 5 | -type | |
| 6 | - P = record a: I64; b: Foo; end; | |
| 7 | - Q = record a: I64; end; | |
| 8 | - | |
| 9 | -var g: Bar; | |
| 10 | - h: I64; | |
| 11 | - | |
| 12 | -proc f(x: I64): I64; | |
| 13 | -var b: BOOL; | |
| 14 | -begin | |
| 15 | - b := x; | |
| 16 | - x := y + 1; | |
| 17 | - x := y * 2; | |
| 18 | - if x = 1 then | |
| 19 | - x := (x + 2) * b; | |
| 20 | - Out.int(z); | |
| 21 | - end; | |
| 22 | - return x + true; | |
| 23 | -end f; | |
| 24 | - | |
| 25 | -proc g2(): Q; | |
| 26 | -var q: Q; | |
| 27 | -begin | |
| 28 | - q.c := 1; | |
| 29 | - h := g; | |
| 30 | - Out.str("hi") | |
| 31 | - return q; | |
| 32 | -end g2; | |
| 33 | - | |
| 34 | -proc main*(); | |
| 35 | -begin | |
| 36 | - Out.int(f(1)); | |
| 37 | - Out.int(nope(2)); | |
| 38 | -end main; | |
| 39 | - | |
| 40 | -end Recover. |
| @@ -1,22 +0,0 @@ | ||
| 1 | -test/err/Resync.raz:10:5: error: expected ";", found a | |
| 2 | - 10 | end a; | |
| 3 | - | ^ | |
| 4 | -test/err/Resync.raz:14:31: error: expected ";", found "end" | |
| 5 | - 14 | while x > 0 do x := x - 1 end; | |
| 6 | - | ^^^ | |
| 7 | -test/err/Resync.raz:15:10: error: expected an expression, found ")" | |
| 8 | - 15 | x := ) + 2; | |
| 9 | - | ^ | |
| 10 | -test/err/Resync.raz:16:11: error: match needs a variant or an enumeration, found I64 | |
| 11 | - 16 | match x | |
| 12 | - | ^ | |
| 13 | -test/err/Resync.raz:23:13: error: expected an expression, found ";" | |
| 14 | - 23 | x := 1 +; | |
| 15 | - | ^ | |
| 16 | -test/err/Resync.raz:23:14: error: expected "end", found "proc" | |
| 17 | - 23 | x := 1 +; | |
| 18 | - | ^ | |
| 19 | -test/err/Resync.raz:27:10: error: can't use BOOL as I64 | |
| 20 | - 27 | x := false; | |
| 21 | - | ^^^^^ | |
| 22 | -raz: 7 errors |
| @@ -1,35 +0,0 @@ | ||
| 1 | -module Resync; | |
| 2 | - | |
| 3 | -import Out; | |
| 4 | - | |
| 5 | -proc a(x: I64); | |
| 6 | -begin | |
| 7 | - if x = 1 then | |
| 8 | - x := 2; | |
| 9 | - Out.int(x); | |
| 10 | -end a; | |
| 11 | - | |
| 12 | -proc b(x: I64); | |
| 13 | -begin | |
| 14 | - while x > 0 do x := x - 1 end; | |
| 15 | - x := ) + 2; | |
| 16 | - match x | |
| 17 | - | 1: x := true; | |
| 18 | - end; | |
| 19 | -end b; | |
| 20 | - | |
| 21 | -proc c(x: I64); | |
| 22 | -begin | |
| 23 | - x := 1 +; | |
| 24 | - | |
| 25 | -proc d(x: I64); | |
| 26 | -begin | |
| 27 | - x := false; | |
| 28 | -end d; | |
| 29 | - | |
| 30 | -proc main*(); | |
| 31 | -begin | |
| 32 | - a(1); b(2); c(3); d(4); | |
| 33 | -end main; | |
| 34 | - | |
| 35 | -end Resync. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanBigDec.raz:5:10: error: 9223372036854775808 is too big for I64 | |
| 2 | - 5 | x := 9223372036854775808; | |
| 3 | - | ^^^^^^^^^^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanBigDec; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; | |
| 4 | -begin | |
| 5 | - x := 9223372036854775808; | |
| 6 | -end; | |
| 7 | -end ScanBigDec. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanBigHex.raz:5:10: error: 10000000000000000 is too big for U64 | |
| 2 | - 5 | x := 10000000000000000H; | |
| 3 | - | ^^^^^^^^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanBigHex; | |
| 2 | -proc main*; | |
| 3 | -var x: U64; | |
| 4 | -begin | |
| 5 | - x := 10000000000000000H; | |
| 6 | -end; | |
| 7 | -end ScanBigHex. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanCharEmpty.raz:5:10: error: empty character | |
| 2 | - 5 | c := ''; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanCharEmpty; | |
| 2 | -proc main*; | |
| 3 | -var c: U8; | |
| 4 | -begin | |
| 5 | - c := ''; | |
| 6 | -end; | |
| 7 | -end ScanCharEmpty. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanCharOpen.raz:5:10: error: character not closed | |
| 2 | - 5 | c := 'ab'; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanCharOpen; | |
| 2 | -proc main*; | |
| 3 | -var c: U8; | |
| 4 | -begin | |
| 5 | - c := 'ab'; | |
| 6 | -end; | |
| 7 | -end ScanCharOpen. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanCodePoint.raz:5:11: error: 110000 isn't a code point | |
| 2 | - 5 | s := "\u{110000}"; | |
| 3 | - | ^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanCodePoint; | |
| 2 | -proc main*; | |
| 3 | -var s: [4]U8; | |
| 4 | -begin | |
| 5 | - s := "\u{110000}"; | |
| 6 | -end; | |
| 7 | -end ScanCodePoint. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanComment.raz:4:5: error: comment not closed | |
| 2 | - 4 | (* never closed | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module ScanComment; | |
| 2 | -proc main*; | |
| 3 | -begin | |
| 4 | - (* never closed | |
| 5 | -end; | |
| 6 | -end ScanComment. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanExponent.raz:5:10: error: expected a digit in the exponent | |
| 2 | - 5 | x := 1.5E+; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanExponent; | |
| 2 | -proc main*; | |
| 3 | -var x: F64; | |
| 4 | -begin | |
| 5 | - x := 1.5E+; | |
| 6 | -end; | |
| 7 | -end ScanExponent. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanHexChar.raz:5:11: error: \x is only for strings | |
| 2 | - 5 | c := '\x41'; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanHexChar; | |
| 2 | -proc main*; | |
| 3 | -var c: U8; | |
| 4 | -begin | |
| 5 | - c := '\x41'; | |
| 6 | -end; | |
| 7 | -end ScanHexChar. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanHexDigits.raz:5:11: error: \x needs two hex digits | |
| 2 | - 5 | s := "\xZ1"; | |
| 3 | - | ^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanHexDigits; | |
| 2 | -proc main*; | |
| 3 | -var s: [4]U8; | |
| 4 | -begin | |
| 5 | - s := "\xZ1"; | |
| 6 | -end; | |
| 7 | -end ScanHexDigits. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanHexH.raz:5:10: error: a hex number ends with H | |
| 2 | - 5 | x := 12A; | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanHexH; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; | |
| 4 | -begin | |
| 5 | - x := 12A; | |
| 6 | -end; | |
| 7 | -end ScanHexH. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanMain.raz:2:6: error: main must be proc main* or proc main*: I64 | |
| 2 | - 2 | proc main*(_n: I64); | |
| 3 | - | ^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,5 +0,0 @@ | ||
| 1 | -module ScanMain; | |
| 2 | -proc main*(_n: I64); | |
| 3 | -begin | |
| 4 | -end; | |
| 5 | -end ScanMain. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanName.raz:4:5: error: a name has at most 63 characters | |
| 2 | - 4 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; | |
| 3 | - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module ScanName; | |
| 2 | -proc main*; | |
| 3 | -begin | |
| 4 | - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; | |
| 5 | -end; | |
| 6 | -end ScanName. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,7 +0,0 @@ | ||
| 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.
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanRealBig.raz:5:10: error: 1.8E308 is out of the range of F64 | |
| 2 | - 5 | x := 1.8E308; | |
| 3 | - | ^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanRealBig; | |
| 2 | -proc main*; | |
| 3 | -var x: F64; | |
| 4 | -begin | |
| 5 | - x := 1.8E308; | |
| 6 | -end; | |
| 7 | -end ScanRealBig. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanRealHex; | |
| 2 | -proc main*; | |
| 3 | -var x: F64; | |
| 4 | -begin | |
| 5 | - x := 1A.5; | |
| 6 | -end; | |
| 7 | -end ScanRealHex. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanStringOpen.raz:5:10: error: string not closed | |
| 2 | - 5 | s := "abc; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanStringOpen; | |
| 2 | -proc main*; | |
| 3 | -var s: [4]U8; | |
| 4 | -begin | |
| 5 | - s := "abc; | |
| 6 | -end; | |
| 7 | -end ScanStringOpen. |
| @@ -1,7 +0,0 @@ | ||
| 1 | -test/err/ScanTwice.raz:4:5: error: x is declared twice | |
| 2 | - 4 | x: I64; | |
| 3 | - | ^ | |
| 4 | -test/err/ScanTwice.raz:3:5: note: the first one is here | |
| 5 | - 3 | var x: I64; | |
| 6 | - | ^ | |
| 7 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module ScanTwice; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; | |
| 4 | - x: I64; | |
| 5 | -begin | |
| 6 | - | |
| 7 | -end; | |
| 8 | -end ScanTwice. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanUBad.raz:5:11: error: expected hex digits and "}" after \u{ | |
| 2 | - 5 | s := "\u{41"; | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanUBad; | |
| 2 | -proc main*; | |
| 3 | -var s: [4]U8; | |
| 4 | -begin | |
| 5 | - s := "\u{41"; | |
| 6 | -end; | |
| 7 | -end ScanUBad. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanUBig; | |
| 2 | -proc main*; | |
| 3 | -var s: [4]U8; | |
| 4 | -begin | |
| 5 | - s := "\u{1234567}"; | |
| 6 | -end; | |
| 7 | -end ScanUBig. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanUBrace.raz:5:11: error: expected "{" after \u | |
| 2 | - 5 | s := "\u0041"; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanUBrace; | |
| 2 | -proc main*; | |
| 3 | -var s: [4]U8; | |
| 4 | -begin | |
| 5 | - s := "\u0041"; | |
| 6 | -end; | |
| 7 | -end ScanUBrace. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/ScanUtf8.raz:5:11: error: invalid UTF-8 | |
| 2 | - 5 | s := "ÿ"; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module ScanUtf8; | |
| 2 | -proc main*; | |
| 3 | -var s: [4]U8; | |
| 4 | -begin | |
| 5 | - s := "ÿ"; | |
| 6 | -end; | |
| 7 | -end ScanUtf8. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/SlipAnd.raz:5:16: error: "and" is written and, not && | |
| 2 | - 5 | if (x = 1) && (y = 2) then x := 2; end; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipAnd; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - if (x = 1) && (y = 2) then x := 2; end; | |
| 6 | -end; | |
| 7 | -end SlipAnd. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/SlipAssign.raz:5:5: error: x isn't a statement | |
| 2 | - 5 | x = 1; | |
| 3 | - | ^ | |
| 4 | -help: assignment is written := | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipAssign; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - x = 1; | |
| 6 | -end; | |
| 7 | -end SlipAssign. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/SlipBrace.raz:5:14: error: expected "then", found "{" | |
| 2 | - 5 | if x = 1 { x := 2 } | |
| 3 | - | ^ | |
| 4 | -help: a block is written "then" ... end | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipBrace; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - if x = 1 { x := 2 } | |
| 6 | -end; | |
| 7 | -end SlipBrace. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/SlipDo.raz:5:17: error: expected "do", found "{" | |
| 2 | - 5 | while x < 3 { x := x + 1 } | |
| 3 | - | ^ | |
| 4 | -help: a block is written "do" ... end | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipDo; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - while x < 3 { x := x + 1 } | |
| 6 | -end; | |
| 7 | -end SlipDo. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/SlipElif.raz:5:27: error: elif isn't declared | |
| 2 | - 5 | if x = 1 then x := 2; elif x = 3 then x := 4; end; | |
| 3 | - | ^^^^ | |
| 4 | -help: raz writes elsif | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipElif; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - if x = 1 then x := 2; elif x = 3 then x := 4; end; | |
| 6 | -end; | |
| 7 | -end SlipElif. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/SlipEql.raz:5:10: error: comparing is written =, not == | |
| 2 | - 5 | if x == 1 then x := 2; end; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipEql; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - if x == 1 then x := 2; end; | |
| 6 | -end; | |
| 7 | -end SlipEql. |
| @@ -1,10 +0,0 @@ | ||
| 1 | -test/err/SlipMany.raz:5:10: error: "not equal" is written #, not != | |
| 2 | - 5 | if x != 1 && z then x := y; end; | |
| 3 | - | ^^ | |
| 4 | -test/err/SlipMany.raz:5:15: error: "and" is written and, not && | |
| 5 | - 5 | if x != 1 && z then x := y; end; | |
| 6 | - | ^^ | |
| 7 | -test/err/SlipMany.raz:5:18: error: z isn't declared | |
| 8 | - 5 | if x != 1 && z then x := y; end; | |
| 9 | - | ^ | |
| 10 | -raz: 3 errors |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipMany; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - if x != 1 && z then x := y; end; | |
| 6 | -end; | |
| 7 | -end SlipMany. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/SlipNeq.raz:5:10: error: "not equal" is written #, not != | |
| 2 | - 5 | if x != 1 then x := 2; end; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipNeq; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - if x != 1 then x := 2; end; | |
| 6 | -end; | |
| 7 | -end SlipNeq. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/SlipNot.raz:5:8: error: "not" is written not, not ! | |
| 2 | - 5 | if ! (x = 1) then x := 2; end; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipNot; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - if ! (x = 1) then x := 2; end; | |
| 6 | -end; | |
| 7 | -end SlipNot. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/SlipOr.raz:5:16: error: "or" is written or, not || | |
| 2 | - 5 | if (x = 1) || (y = 2) then x := 2; end; | |
| 3 | - | ^^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module SlipOr; | |
| 2 | -proc main*; | |
| 3 | -var x, y: I64; | |
| 4 | -begin | |
| 5 | - if (x = 1) || (y = 2) then x := 2; end; | |
| 6 | -end; | |
| 7 | -end SlipOr. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module StmtArgKind; | |
| 2 | -import Mem, L := List(Mem.Page); | |
| 3 | - | |
| 4 | -var l: L.List; | |
| 5 | - | |
| 6 | -end StmtArgKind. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtAssignConst.raz:5:5: error: can't assign to k | |
| 2 | - 5 | k := 2; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module StmtAssignConst; | |
| 2 | -const k = 1; | |
| 3 | -proc main*; | |
| 4 | -begin | |
| 5 | - k := 2; | |
| 6 | -end; | |
| 7 | -end StmtAssignConst. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,9 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtCaseName.raz:11:7: error: expected a case, found a number | |
| 2 | - 11 | | 5: | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,14 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtCaseTwice.raz:12:7: error: dot has two arms | |
| 2 | - 12 | | dot: | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,16 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtDot.raz:2:12: error: expected ".", found ";" | |
| 2 | - 2 | end StmtDot; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,2 +0,0 @@ | ||
| 1 | -module StmtDot; | |
| 2 | -end StmtDot; |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtElseLast.raz:12:7: error: else must be the last arm | |
| 2 | - 12 | | dot: | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,15 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtEnd.raz:5:12: error: expected "end", found ")" | |
| 2 | - 5 | a := 1; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module StmtEnd; | |
| 2 | -proc main*; | |
| 3 | -var a: I64; | |
| 4 | -begin | |
| 5 | - a := 1; | |
| 6 | -) | |
| 7 | -end; | |
| 8 | -end StmtEnd. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtEndName.raz:2:5: error: expected StmtEndName, found Other | |
| 2 | - 2 | end Other. | |
| 3 | - | ^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,2 +0,0 @@ | ||
| 1 | -module StmtEndName; | |
| 2 | -end Other. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module StmtErrType; | |
| 2 | -const k: I64 = "a"; | |
| 3 | -end StmtErrType. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,15 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtFieldName.raz:11:14: error: expected a name, found a number | |
| 2 | - 11 | | circle(5): | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,15 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,7 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,7 +0,0 @@ | ||
| 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. |
| @@ -1,7 +0,0 @@ | ||
| 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 |
| @@ -1,4 +0,0 @@ | ||
| 1 | -module StmtForwardTwice; | |
| 2 | -proc f; forward; | |
| 3 | -proc f; forward; | |
| 4 | -end StmtForwardTwice. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtFwdPtr.raz:2:11: error: Missing isn't declared | |
| 2 | - 2 | type P = ^Missing; | |
| 3 | - | ^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module StmtFwdPtr; | |
| 2 | -type P = ^Missing; | |
| 3 | -end StmtFwdPtr. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtImportName.raz:2:8: error: expected a module name, found a number | |
| 2 | - 2 | import 5; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module StmtImportName; | |
| 2 | -import 5; | |
| 3 | -end StmtImportName. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtManyFields.raz:11:17: error: more names than circle has fields | |
| 2 | - 11 | | circle(r, x): | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,15 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module StmtManyTypeArgs; | |
| 2 | -import L := List(I64, I64); | |
| 3 | - | |
| 4 | -var l: L.List; | |
| 5 | - | |
| 6 | -end StmtManyTypeArgs. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module StmtNeedProc; | |
| 2 | -import Str, M := Map([]U8, I64, I64, Str.eq); | |
| 3 | - | |
| 4 | -var m: M.Map; | |
| 5 | - | |
| 6 | -end StmtNeedProc. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module StmtNeedType; | |
| 2 | -import Str, M := Map(Str.cmp, I64, Str.cmp, Str.eq); | |
| 3 | - | |
| 4 | -var m: M.Map; | |
| 5 | - | |
| 6 | -end StmtNeedType. |
| @@ -1,7 +0,0 @@ | ||
| 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 |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module StmtNest; | |
| 2 | -proc main*; | |
| 3 | - proc inner; forward; | |
| 4 | -begin | |
| 5 | -end; | |
| 6 | -end StmtNest. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtNeverDefined.raz:3:21: error: f is declared forward but never defined | |
| 2 | - 3 | end StmtNeverDefined. | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module StmtNeverDefined; | |
| 2 | -proc f; forward; | |
| 3 | -end StmtNeverDefined. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtNoModule.raz:2:8: error: can't find module Nothing | |
| 2 | - 2 | import Nothing; | |
| 3 | - | ^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module StmtNoModule; | |
| 2 | -import Nothing; | |
| 3 | -end StmtNoModule. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,15 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtNotStmt.raz:6:5: error: a value isn't a statement | |
| 2 | - 6 | r.a; | |
| 3 | - | ^^^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,6 +0,0 @@ | ||
| 1 | -module StmtParamName; | |
| 2 | -import L := StmtParam(I64); | |
| 3 | - | |
| 4 | -var l: L.T; | |
| 5 | - | |
| 6 | -end StmtParamName. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtProcName.raz:2:23: error: expected main, found mian | |
| 2 | - 2 | proc main*; begin end mian; | |
| 3 | - | ^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module StmtProcName; | |
| 2 | -proc main*; begin end mian; | |
| 3 | -end StmtProcName. |
| @@ -1,4 +0,0 @@ | ||
| 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 |
| @@ -1,8 +0,0 @@ | ||
| 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. |
| @@ -1,10 +0,0 @@ | ||
| 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:2:6: note: the signature is here | |
| 5 | - 2 | proc f(a: I64); forward; | |
| 6 | - | ^ | |
| 7 | -test/err/StmtSigForward.raz:4:19: error: f is declared forward but never defined | |
| 8 | - 4 | end StmtSigForward. | |
| 9 | - | ^ | |
| 10 | -raz: 2 errors |
| @@ -1,4 +0,0 @@ | ||
| 1 | -module StmtSigForward; | |
| 2 | -proc f(a: I64); forward; | |
| 3 | -proc f(a: BOOL); begin end; | |
| 4 | -end StmtSigForward. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtStatement.raz:5:13: error: expected a statement, found ")" | |
| 2 | - 5 | a := 1; ) | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module StmtStatement; | |
| 2 | -proc main*; | |
| 3 | -var a: I64; | |
| 4 | -begin | |
| 5 | - a := 1; ) | |
| 6 | -end; | |
| 7 | -end StmtStatement. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/StmtVarOrProc.raz:2:8: error: expected "proc" or "var", found a number | |
| 2 | - 2 | extern 5; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module StmtVarOrProc; | |
| 2 | -extern 5; | |
| 3 | -end StmtVarOrProc. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/mods/StmtOther.raz:1:8: error: expected module StmtOther, found StmtWrong | |
| 2 | - 1 | module StmtWrong; | |
| 3 | - | ^^^^^^^^^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module StmtWrongModule; | |
| 2 | -import StmtOther; | |
| 3 | -end StmtWrongModule. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/TildeBool.raz:5:11: error: "~" needs an integer, found BOOL | |
| 2 | - 5 | b := ~b; | |
| 3 | - | ^ | |
| 4 | -help: a BOOL is negated with not | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module TildeBool; | |
| 2 | -proc main*; | |
| 3 | -var b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - b := ~b; | |
| 6 | -end; | |
| 7 | -end TildeBool. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/Tuple.raz:6:10: error: two returns several results | |
| 2 | - 6 | a := two() + 1; | |
| 3 | - | ^^^^^ | |
| 4 | -help: they go to variables: a, b := two(...) | |
| 5 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module Tuple; | |
| 2 | -proc two: (I64, I64); begin return 1, 2; end; | |
| 3 | -proc main*; | |
| 4 | -var a: I64; | |
| 5 | -begin | |
| 6 | - a := two() + 1; | |
| 7 | -end; | |
| 8 | -end Tuple. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/TwoTypes.raz:6:10: error: can't use List(I32).List as List(I64).List | |
| 2 | - 6 | a := b; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module TwoTypes; | |
| 2 | -import A := List(I64), B := List(I32); | |
| 3 | -proc main*; | |
| 4 | -var a: A.List; b: B.List; | |
| 5 | -begin | |
| 6 | - a := b; | |
| 7 | -end; | |
| 8 | -end TwoTypes. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/Utf.raz:2:5: error: only ASCII outside strings, characters and comments | |
| 2 | - 2 | var é: I64; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module Utf; | |
| 2 | -var é: I64; | |
| 3 | -end Utf. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -test/err/Volatile.raz:6:10: error: can't use ^VOLATILE I64 as ^I64 | |
| 2 | - 6 | q := p; | |
| 3 | - | ^ | |
| 4 | -raz: 1 error |
| @@ -1,8 +0,0 @@ | ||
| 1 | -module Volatile; | |
| 2 | -proc main*; | |
| 3 | -var x: I64; p: ^VOLATILE I64; q: ^I64; | |
| 4 | -begin | |
| 5 | - p := ADR(x); | |
| 6 | - q := p; | |
| 7 | -end; | |
| 8 | -end Volatile. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -test/err/XorBools.raz:5:10: error: "xor" needs integers, found BOOL | |
| 2 | - 5 | b := b xor true; | |
| 3 | - | ^ | |
| 4 | -help: BOOLs that differ are # | |
| 5 | -raz: 1 error |
| @@ -1,7 +0,0 @@ | ||
| 1 | -module XorBools; | |
| 2 | -proc main*; | |
| 3 | -var b: BOOL; x: I64; | |
| 4 | -begin | |
| 5 | - b := b xor true; | |
| 6 | -end; | |
| 7 | -end XorBools. |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module Cycle; | |
| 2 | -import CycleB; | |
| 3 | -end Cycle. |
| @@ -1,3 +0,0 @@ | ||
| 1 | -module CycleB; | |
| 2 | -import Cycle; | |
| 3 | -end CycleB. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -module DeclHidden; | |
| 2 | -const shown* = 1; | |
| 3 | -const hidden = 2; | |
| 4 | -end DeclHidden. |
| @@ -1,2 +0,0 @@ | ||
| 1 | -module StmtWrong; | |
| 2 | -end StmtWrong. |
| @@ -1,2 +0,0 @@ | ||
| 1 | -module StmtParam(5); | |
| 2 | -end StmtParam. |
| @@ -4,11 +4,11 @@ | ||
| 4 | 4 | # caller. |
| 5 | 5 | out=build/check |
| 6 | 6 | mkdir -p $out |
| 7 | -./raz -I test/run/mods -o $out/Procs test/run/Procs.raz || exit 1 | |
| 8 | -gdb -batch -ex 'break test/run/Procs.raz:13' -ex run -ex bt $out/Procs > $out/gdb.out 2>&1 | |
| 9 | -for want in 'Breakpoint 1, Procs.odd () at test/run/Procs.raz:13' \ | |
| 10 | - 'in Procs.even () at test/run/Procs.raz:20' \ | |
| 11 | - 'in Procs.main () at test/run/Procs.raz:'; do | |
| 7 | +./raz -I conform/run/mods -o $out/Procs conform/run/Procs.raz || exit 1 | |
| 8 | +gdb -batch -ex 'break conform/run/Procs.raz:13' -ex run -ex bt $out/Procs > $out/gdb.out 2>&1 | |
| 9 | +for want in 'Breakpoint 1, Procs.odd () at conform/run/Procs.raz:13' \ | |
| 10 | + 'in Procs.even () at conform/run/Procs.raz:20' \ | |
| 11 | + 'in Procs.main () at conform/run/Procs.raz:'; do | |
| 12 | 12 | if ! grep -qF "$want" $out/gdb.out; then |
| 13 | 13 | echo "FAIL gdb: no \"$want\""; cat $out/gdb.out; exit 1 |
| 14 | 14 | fi |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/AmpBools.raz:5:10: error: "&" needs integers, found BOOL | |
| 2 | + 5 | b := b & true; | |
| 3 | + | ^ | |
| 4 | +help: BOOLs take and | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/ArrayEqReal.raz:6:8: error: can't compare arrays of reals with "=" | |
| 2 | + 6 | if a = b then end; | |
| 3 | + | ^^^^^ | |
| 4 | +help: -0.0 = 0.0 and a NaN equals nothing, though their bytes say otherwise: write a loop | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/ArrayEqRecord.raz:6:8: error: can't compare arrays of record with "=" | |
| 2 | + 6 | if a = b then end; | |
| 3 | + | ^^^^^ | |
| 4 | +help: write a loop | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ArrayEqTypes.raz:6:8: error: can't compare an array of I64 with one of I32 | |
| 2 | + 6 | if a # b then end; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/Assign.raz:5:10: error: can't use I32 as I64 | |
| 2 | + 5 | a := b; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/AtAnd.raz:5:16: error: "and" needs BOOLs, found I64 | |
| 2 | + 5 | b := b and (x + 1); | |
| 3 | + | ^^^^^^^ | |
| 4 | +help: the bits of integers take & | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtArgType.raz:7:8: error: can't use BOOL as I64 | |
| 2 | + 7 | Id(b); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtBinary.raz:5:10: error: I64 and BOOL are different types | |
| 2 | + 5 | x := (x + 2) * b; | |
| 3 | + | ^^^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtCall.raz:5:10: error: expected a procedure, found I64 | |
| 2 | + 5 | x := x(1); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtCondition.raz:5:8: error: a condition is a BOOL, found I64 | |
| 2 | + 5 | if x + 1 then end; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtConstFit.raz:5:10: error: 3000000005 doesn't fit I32 | |
| 2 | + 5 | x := 5 + 3000000000; | |
| 3 | + | ^^^^^^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtConvert.raz:5:14: error: can't convert BOOL to I64 | |
| 2 | + 5 | x := I64(b); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtDeref.raz:5:10: error: expected a pointer, found I64 | |
| 2 | + 5 | y := x^; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtDivZero.raz:5:10: error: division by zero | |
| 2 | + 5 | x := 7 div (3 - 3); | |
| 3 | + | ^^^^^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtIndex.raz:5:12: error: an index is an integer, found BOOL | |
| 2 | + 5 | x := a[b]; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,7 @@ | ||
| 1 | +conform/err/AtMany.raz:7:16: error: too many arguments: Id takes 1 | |
| 2 | + 7 | x := Id(1, 2 * 3); | |
| 3 | + | ^^^^^ | |
| 4 | +conform/err/AtMany.raz:2:6: note: the signature is here | |
| 5 | + 2 | proc Id(a: I64): I64; | |
| 6 | + | ^^ | |
| 7 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtMatch.raz:5:11: error: match needs a variant or an enumeration, found I64 | |
| 2 | + 5 | match x + 1 do end; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtNegate.raz:5:10: error: can't negate BOOL | |
| 2 | + 5 | x := -b; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtNot.raz:5:14: error: "not" needs a BOOL, found []U8 | |
| 2 | + 5 | b := not s; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtNotValue.raz:5:10: error: I64 is a type, not a value | |
| 2 | + 5 | x := I64 + 1; | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPAdr.raz:5:14: error: ADR needs a variable | |
| 2 | + 5 | p := ADR(1); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPArrayLen.raz:2:9: error: an array's length is from 1 to 2^40, found 0 | |
| 2 | + 2 | var a: [0]I64; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPCantAssign.raz:7:8: error: can't assign to k | |
| 2 | + 7 | a, k := two(); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPChar.raz:5:12: error: unexpected character "?" | |
| 2 | + 5 | a := 1 ? 2; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPComment.raz:5:1: error: comment not closed | |
| 2 | + 5 | (* never closed | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPConstExpr.raz:4:9: error: expected a constant | |
| 2 | + 4 | var a: [n]I64; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPElems.raz:5:10: error: expected 3 elements, found 2 | |
| 2 | + 5 | a := [1, 2]; | |
| 3 | + | ^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPEscape.raz:5:12: error: unknown escape \q | |
| 2 | + 5 | s := "a\q"; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPInc.raz:5:9: error: INC needs an integer variable | |
| 2 | + 5 | INC(a); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPLen.raz:5:14: error: LEN needs an array or a slice, found I64 | |
| 2 | + 5 | a := LEN(a); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPNewVar.raz:5:9: error: NEW needs a pointer variable | |
| 2 | + 5 | NEW(a, a); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPNoResult.raz:8:10: error: p returns nothing | |
| 2 | + 8 | a := p() + 1; | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPNotRecord.raz:5:10: error: expected a record, found I64 | |
| 2 | + 5 | a := a.f; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPNotStmt.raz:5:5: error: a isn't a statement | |
| 2 | + 5 | a; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPSetLit.raz:6:14: error: 1 isn't a name of C | |
| 2 | + 6 | s := {r, 1}; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPStep.raz:5:24: error: the step can't be zero | |
| 2 | + 5 | for i := 1 to 5 by 1 - 1 do end; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtPtrMinus.raz:5:10: error: ^I64 and ^I32 are different types | |
| 2 | + 5 | x := p - q; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtReturn.raz:4:12: error: this procedure returns nothing | |
| 2 | + 4 | return 1 + 2; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtSliceHi.raz:5:15: error: an index is an integer, found BOOL | |
| 2 | + 5 | s := a[0..b]; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtSliceLo.raz:5:12: error: an index is an integer, found BOOL | |
| 2 | + 5 | s := a[b..2]; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtStrCmp.raz:5:8: error: can't compare an array with I64 | |
| 2 | + 5 | if s = x + 1 then end; | |
| 3 | + | ^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/AtVarArg.raz:7:9: error: a var parameter needs a variable | |
| 2 | + 7 | Inc(1 + 2); | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,7 @@ | ||
| 1 | +conform/err/BadProc.raz:2:33: error: cmp doesn't have the signature of hash | |
| 2 | + 2 | import Str, M := Map([]U8, I64, Str.cmp, Str.eq); | |
| 3 | + | ^^^^^^^ | |
| 4 | +lib/Map.raz:4:18: note: the signature is here | |
| 5 | + 4 | module Map(K, V; hash: proc(k: K): U64; eq: proc(a, b: K): BOOL); | |
| 6 | + | ^^^^ | |
| 7 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/BarBools.raz:5:10: error: "|" needs integers, found BOOL | |
| 2 | + 5 | b := b | true; | |
| 3 | + | ^ | |
| 4 | +help: BOOLs take or | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/BigI64.raz:5:10: error: can't use U64 as I64 | |
| 2 | + 5 | i := 0FFFFFFFFFFFFFFFFH; | |
| 3 | + | ^^^^^^^^^^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1 @@ | ||
| 1 | +conform/run/Bounds.raz:8:11: index 4 is out of range for a length of 4 |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/Break.raz:4:5: error: break outside a loop | |
| 2 | + 4 | break; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/mods/CycleB.raz:2:8: error: Cycle imports itself | |
| 2 | + 2 | import Cycle; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/DeclIntConst.raz:3:9: error: expected an integer constant, found 1.5 | |
| 2 | + 3 | var a: [1.5]I64; | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/DeclLitNoField.raz:6:11: error: R has no field b | |
| 2 | + 6 | r := {b: 1}; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/DeclNeedsFields.raz:9:10: error: circle needs its fields | |
| 2 | + 9 | s := circle; | |
| 3 | + | ^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/DeclNoField.raz:6:7: error: R has no field b | |
| 2 | + 6 | r.b := 1; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,10 @@ | ||
| 1 | +conform/err/mods/DeclHidden.raz:3:7: warning: constant hidden is never used | |
| 2 | + 3 | const hidden = 2; | |
| 3 | + | ^^^^^^ | |
| 4 | +conform/err/DeclNotExported.raz:6:21: error: hidden isn't exported by DeclHidden | |
| 5 | + 6 | n := DeclHidden.hidden; | |
| 6 | + | ^^^^^^ | |
| 7 | +conform/err/mods/DeclHidden.raz:3:7: note: hidden is declared here, without a * | |
| 8 | + 3 | const hidden = 2; | |
| 9 | + | ^^^^^^ | |
| 10 | +raz: 1 error, 1 warning |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/DeclNotType.raz:4:8: error: n isn't a type | |
| 2 | + 4 | var a: n; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/DeclSetLitType.raz:6:10: error: expected a set type, found I64 | |
| 2 | + 6 | n := {r}; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/DeclSetNames.raz:6:16: error: a set holds names of an enumeration, found 1 | |
| 2 | + 6 | s := {} + {1}; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/DeclSetUnknown.raz:4:8: error: {} needs a known set type | |
| 2 | + 4 | if {} = {} then end; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/DeferBreak.raz:5:15: error: break outside a loop | |
| 2 | + 5 | defer break; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/DeferDefer.raz:4:11: error: defer can't be deferred | |
| 2 | + 4 | defer defer f; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/DeferReturn.raz:4:11: error: return can't leave a deferred statement | |
| 2 | + 4 | defer return 1; | |
| 3 | + | ^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ErrOrder.raz:5:8: error: "<" doesn't apply to ERROR | |
| 2 | + 5 | if A < B then end; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,7 @@ | ||
| 1 | +conform/err/FirstUseLate.raz:2:18: error: Later isn't declared | |
| 2 | + 2 | import L := List(Later); | |
| 3 | + | ^^^^^ | |
| 4 | +conform/err/FirstUseLate.raz:4:8: note: the instance is made here, where it is first used | |
| 5 | + 4 | var l: L.List; (* made here, before Later is declared *) | |
| 6 | + | ^ | |
| 7 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/GenBoolOp.raz:6:10: error: "+" doesn't apply to BOOL | |
| 2 | + 6 | b := b + b; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,10 @@ | ||
| 1 | +conform/err/GenConstOverflow.raz:5:12: error: the constant is too big for I64 | |
| 2 | + 5 | Over = Big + 1; | |
| 3 | + | ^^^^^^^ | |
| 4 | +conform/err/GenConstOverflow.raz:6:13: error: the constant is too big for I64 | |
| 5 | + 6 | Twice = 4611686018427387904 * 2; | |
| 6 | + | ^^^^^^^^^^^^^^^^^^^^^^^ | |
| 7 | +conform/err/GenConstOverflow.raz:7:13: error: the constant is too big for I64 | |
| 8 | + 7 | Under = -Big - 2; | |
| 9 | + | ^^^^^^^^ | |
| 10 | +raz: 3 errors |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/GenConvertString.raz:6:14: error: can't convert a string | |
| 2 | + 6 | x := I64("a"); | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/GenDivOverflow.raz:6:10: error: division overflows | |
| 2 | + 6 | x := (-9223372036854775807 - 1) div (0 - 1); | |
| 3 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/GenEnumOp.raz:6:10: error: "+" doesn't apply to C | |
| 2 | + 6 | c := c + c; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,5 @@ | ||
| 1 | +conform/err/GenIntReal.raz:6:10: error: I64 and F64 are different types | |
| 2 | + 6 | y := x + y; | |
| 3 | + | ^^^^^ | |
| 4 | +help: convert one to the other's type, as in I64(y) | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/GenIntTypes.raz:6:10: error: I32 and I64 are different types | |
| 2 | + 6 | b := a + b; | |
| 3 | + | ^^^^^ | |
| 4 | +help: convert one to the other's type, as in I32(b) | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/GenNotVariable.raz:5:7: error: a var parameter needs a variable | |
| 2 | + 5 | P(1); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/GenPtrOp.raz:6:10: error: "+" doesn't apply to ^I64 | |
| 2 | + 6 | b := p + p; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/GenSetOp.raz:6:10: error: "<" doesn't apply to CS | |
| 2 | + 6 | b := a < a; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,5 @@ | ||
| 1 | +conform/err/GenSlash.raz:6:10: error: "/" divides reals, not integers | |
| 2 | + 6 | x := 6 / 3; | |
| 3 | + | ^^^^^ | |
| 4 | +help: to divide integers, write 6 div 3 | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/GenSlashVar.raz:6:10: error: "/" divides reals, not integers | |
| 2 | + 6 | x := x / y; | |
| 3 | + | ^^^^^ | |
| 4 | +help: to divide integers, write x div y | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,7 @@ | ||
| 1 | +conform/err/GenTooFew.raz:6:14: error: too few arguments: Id takes 1 | |
| 2 | + 6 | x := Id(); | |
| 3 | + | ^ | |
| 4 | +conform/err/GenTooFew.raz:2:6: note: the signature is here | |
| 5 | + 2 | proc Id(a: I64): I64; begin return a; end; | |
| 6 | + | ^^ | |
| 7 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/GenTooFewValue.raz:6:8: error: too few arguments | |
| 2 | + 6 | f(); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/GenTooManyValue.raz:6:10: error: too many arguments | |
| 2 | + 6 | f(1, 2); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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 @@ | ||
| 1 | +conform/run/Kinds.raz:92:16: 5 isn't a position of Color |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/Match.raz:9:5: error: no arm for c | |
| 2 | + 9 | end; | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/Mixed.raz:6:10: error: F32 and F64 are different types | |
| 2 | + 6 | y := x + y; | |
| 3 | + | ^^^^^ | |
| 4 | +help: convert one to the other's type, as in F32(y) | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/NegU64.raz:5:10: error: -1 doesn't fit U64 | |
| 2 | + 5 | u := -1; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/NoArgs.raz:2:8: error: List needs a type for T | |
| 2 | + 2 | import List; | |
| 3 | + | ^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/NotGeneric.raz:2:8: error: Str isn't generic | |
| 2 | + 2 | import S := Str(I64); | |
| 3 | + | ^^^^^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/NotInt.raz:5:14: error: "not" needs a BOOL, found I64 | |
| 2 | + 5 | x := not x; | |
| 3 | + | ^ | |
| 4 | +help: the bits of an integer flip with ~ | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/NoteBuiltin.raz:5:10: error: len isn't declared | |
| 2 | + 5 | x := len(y); | |
| 3 | + | ^^^ | |
| 4 | +help: did you mean LEN? | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/NoteExport.raz:6:9: error: Int isn't exported by Out | |
| 2 | + 6 | Out.Int(x); | |
| 3 | + | ^^^ | |
| 4 | +help: did you mean int? | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/NoteField.raz:6:7: error: P has no field cuont | |
| 2 | + 6 | p.cuont := 1; | |
| 3 | + | ^^^^^ | |
| 4 | +help: did you mean count? | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/NoteImport.raz:5:5: error: Fmt isn't declared | |
| 2 | + 5 | Fmt.print(x); | |
| 3 | + | ^^^ | |
| 4 | +help: Fmt is a module: import Fmt | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/NoteLocal.raz:6:5: error: cuont isn't declared | |
| 2 | + 6 | cuont := 1; | |
| 3 | + | ^^^^^ | |
| 4 | +help: did you mean count? | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/OrInts.raz:5:10: error: "or" needs BOOLs, found I64 | |
| 2 | + 5 | x := x or 1; | |
| 3 | + | ^ | |
| 4 | +help: the bits of integers take | | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,13 @@ | ||
| 1 | +conform/err/PackedAddress.raz:15:14: error: a field of a packed record has no address | |
| 2 | + 15 | p := ADR(h.len); | |
| 3 | + | ^^^^^ | |
| 4 | +conform/err/PackedAddress.raz:16:9: error: a field of a packed record can't be a var parameter | |
| 5 | + 16 | put(h.len); | |
| 6 | + | ^^^^^ | |
| 7 | +conform/err/PackedAddress.raz:17:10: error: can't make a slice of a field of a packed record | |
| 8 | + 17 | s := h.vals[0..1]; | |
| 9 | + | ^^^^^^ | |
| 10 | +conform/err/PackedAddress.raz:19:5: error: a field of a packed record can't be volatile | |
| 11 | + 19 | q^.len := 2; | |
| 12 | + | ^^ | |
| 13 | +raz: 4 errors |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/PassOnTypes.raz:10:12: error: expected the results (BOOL, I64), found (I64, BOOL) | |
| 2 | + 10 | return two(n); | |
| 3 | + | ^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/PtrArray.raz:6:5: error: a pointer to an array is indexed as p^[i] | |
| 2 | + 6 | p[1] := 0; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,31 @@ | ||
| 1 | +conform/err/Recover.raz:6:27: error: Foo isn't declared | |
| 2 | + 6 | P = record a: I64; b: Foo; end; | |
| 3 | + | ^^^ | |
| 4 | +conform/err/Recover.raz:9:8: error: Bar isn't declared | |
| 5 | + 9 | var g: Bar; | |
| 6 | + | ^^^ | |
| 7 | +conform/err/Recover.raz:15:10: error: can't use I64 as BOOL | |
| 8 | + 15 | b := x; | |
| 9 | + | ^ | |
| 10 | +conform/err/Recover.raz:16:10: error: y isn't declared | |
| 11 | + 16 | x := y + 1; | |
| 12 | + | ^ | |
| 13 | +conform/err/Recover.raz:19:14: error: I64 and BOOL are different types | |
| 14 | + 19 | x := (x + 2) * b; | |
| 15 | + | ^^^^^^^^^^^ | |
| 16 | +conform/err/Recover.raz:20:17: error: z isn't declared | |
| 17 | + 20 | Out.int(z); | |
| 18 | + | ^ | |
| 19 | +conform/err/Recover.raz:22:12: error: I64 and BOOL are different types | |
| 20 | + 22 | return x + true; | |
| 21 | + | ^^^^^^^^ | |
| 22 | +conform/err/Recover.raz:28:7: error: Q has no field c | |
| 23 | + 28 | q.c := 1; | |
| 24 | + | ^ | |
| 25 | +conform/err/Recover.raz:30:18: error: expected ";", found "return" | |
| 26 | + 30 | Out.str("hi") | |
| 27 | + | ^ | |
| 28 | +conform/err/Recover.raz:37:13: error: nope isn't declared | |
| 29 | + 37 | Out.int(nope(2)); | |
| 30 | + | ^^^^ | |
| 31 | +raz: 10 errors |
| @@ -0,0 +1,22 @@ | ||
| 1 | +conform/err/Resync.raz:10:5: error: expected ";", found a | |
| 2 | + 10 | end a; | |
| 3 | + | ^ | |
| 4 | +conform/err/Resync.raz:14:31: error: expected ";", found "end" | |
| 5 | + 14 | while x > 0 do x := x - 1 end; | |
| 6 | + | ^^^ | |
| 7 | +conform/err/Resync.raz:15:10: error: expected an expression, found ")" | |
| 8 | + 15 | x := ) + 2; | |
| 9 | + | ^ | |
| 10 | +conform/err/Resync.raz:16:11: error: match needs a variant or an enumeration, found I64 | |
| 11 | + 16 | match x | |
| 12 | + | ^ | |
| 13 | +conform/err/Resync.raz:23:13: error: expected an expression, found ";" | |
| 14 | + 23 | x := 1 +; | |
| 15 | + | ^ | |
| 16 | +conform/err/Resync.raz:23:14: error: expected "end", found "proc" | |
| 17 | + 23 | x := 1 +; | |
| 18 | + | ^ | |
| 19 | +conform/err/Resync.raz:27:10: error: can't use BOOL as I64 | |
| 20 | + 27 | x := false; | |
| 21 | + | ^^^^^ | |
| 22 | +raz: 7 errors |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanBigDec.raz:5:10: error: 9223372036854775808 is too big for I64 | |
| 2 | + 5 | x := 9223372036854775808; | |
| 3 | + | ^^^^^^^^^^^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanBigHex.raz:5:10: error: 10000000000000000 is too big for U64 | |
| 2 | + 5 | x := 10000000000000000H; | |
| 3 | + | ^^^^^^^^^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanCharEmpty.raz:5:10: error: empty character | |
| 2 | + 5 | c := ''; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanCharOpen.raz:5:10: error: character not closed | |
| 2 | + 5 | c := 'ab'; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/ScanComment.raz:4:5: error: comment not closed | |
| 2 | + 4 | (* never closed | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/ScanHexChar.raz:5:11: error: \x is only for strings | |
| 2 | + 5 | c := '\x41'; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanHexDigits.raz:5:11: error: \x needs two hex digits | |
| 2 | + 5 | s := "\xZ1"; | |
| 3 | + | ^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanHexH.raz:5:10: error: a hex number ends with H | |
| 2 | + 5 | x := 12A; | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanMain.raz:2:6: error: main must be proc main* or proc main*: I64 | |
| 2 | + 2 | proc main*(_n: I64); | |
| 3 | + | ^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanName.raz:4:5: error: a name has at most 63 characters | |
| 2 | + 4 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; | |
| 3 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanNameDigit.raz:5:10: error: a name can't start with a digit | |
| 2 | + 5 | x := 12abc; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
Binary file; the patch has it.
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanRealBig.raz:5:10: error: 1.8E308 is out of the range of F64 | |
| 2 | + 5 | x := 1.8E308; | |
| 3 | + | ^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/ScanStringOpen.raz:5:10: error: string not closed | |
| 2 | + 5 | s := "abc; | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,7 @@ | ||
| 1 | +conform/err/ScanTwice.raz:4:5: error: x is declared twice | |
| 2 | + 4 | x: I64; | |
| 3 | + | ^ | |
| 4 | +conform/err/ScanTwice.raz:3:5: note: the first one is here | |
| 5 | + 3 | var x: I64; | |
| 6 | + | ^ | |
| 7 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/ScanUBrace.raz:5:11: error: expected "{" after \u | |
| 2 | + 5 | s := "\u0041"; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/ScanUtf8.raz:5:11: error: invalid UTF-8 | |
| 2 | + 5 | s := "ÿ"; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1 @@ | ||
| 1 | +conform/run/SliceBounds.raz:10:23: slice 9..6 is out of range for a length of 8 |
| @@ -0,0 +1 @@ | ||
| 1 | +conform/run/SliceIndex.raz:11:11: index 3 is out of range for a length of 3 |
| @@ -0,0 +1 @@ | ||
| 1 | +conform/run/SlicePtrBackwards.raz:11:23: slice 2..0 runs backwards |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/SlipAnd.raz:5:16: error: "and" is written and, not && | |
| 2 | + 5 | if (x = 1) && (y = 2) then x := 2; end; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/SlipAssign.raz:5:5: error: x isn't a statement | |
| 2 | + 5 | x = 1; | |
| 3 | + | ^ | |
| 4 | +help: assignment is written := | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/SlipBrace.raz:5:14: error: expected "then", found "{" | |
| 2 | + 5 | if x = 1 { x := 2 } | |
| 3 | + | ^ | |
| 4 | +help: a block is written "then" ... end | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/SlipDo.raz:5:17: error: expected "do", found "{" | |
| 2 | + 5 | while x < 3 { x := x + 1 } | |
| 3 | + | ^ | |
| 4 | +help: a block is written "do" ... end | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/SlipElif.raz:5:27: error: elif isn't declared | |
| 2 | + 5 | if x = 1 then x := 2; elif x = 3 then x := 4; end; | |
| 3 | + | ^^^^ | |
| 4 | +help: raz writes elsif | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/SlipEql.raz:5:10: error: comparing is written =, not == | |
| 2 | + 5 | if x == 1 then x := 2; end; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,10 @@ | ||
| 1 | +conform/err/SlipMany.raz:5:10: error: "not equal" is written #, not != | |
| 2 | + 5 | if x != 1 && z then x := y; end; | |
| 3 | + | ^^ | |
| 4 | +conform/err/SlipMany.raz:5:15: error: "and" is written and, not && | |
| 5 | + 5 | if x != 1 && z then x := y; end; | |
| 6 | + | ^^ | |
| 7 | +conform/err/SlipMany.raz:5:18: error: z isn't declared | |
| 8 | + 5 | if x != 1 && z then x := y; end; | |
| 9 | + | ^ | |
| 10 | +raz: 3 errors |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/SlipNeq.raz:5:10: error: "not equal" is written #, not != | |
| 2 | + 5 | if x != 1 then x := 2; end; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/SlipNot.raz:5:8: error: "not" is written not, not ! | |
| 2 | + 5 | if ! (x = 1) then x := 2; end; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/SlipOr.raz:5:16: error: "or" is written or, not || | |
| 2 | + 5 | if (x = 1) || (y = 2) then x := 2; end; | |
| 3 | + | ^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/StmtAssignConst.raz:5:5: error: can't assign to k | |
| 2 | + 5 | k := 2; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/StmtCaseName.raz:11:7: error: expected a case, found a number | |
| 2 | + 11 | | 5: | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/StmtCaseTwice.raz:12:7: error: dot has two arms | |
| 2 | + 12 | | dot: | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/StmtDot.raz:2:12: error: expected ".", found ";" | |
| 2 | + 2 | end StmtDot; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/StmtElseLast.raz:12:7: error: else must be the last arm | |
| 2 | + 12 | | dot: | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/StmtEnd.raz:5:12: error: expected "end", found ")" | |
| 2 | + 5 | a := 1; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/StmtEndName.raz:2:5: error: expected StmtEndName, found Other | |
| 2 | + 2 | end Other. | |
| 3 | + | ^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/StmtFieldName.raz:11:14: error: expected a name, found a number | |
| 2 | + 11 | | circle(5): | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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 | +conform/err/StmtForwardTwice.raz:3:9: error: f is declared forward twice | |
| 2 | + 3 | proc f; forward; | |
| 3 | + | ^^^^^^^ | |
| 4 | +conform/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 | +conform/err/StmtFwdPtr.raz:2:11: error: Missing isn't declared | |
| 2 | + 2 | type P = ^Missing; | |
| 3 | + | ^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,7 @@ | ||
| 1 | +conform/err/StmtNest.raz:3:3: error: procedures don't nest | |
| 2 | + 3 | proc inner; forward; | |
| 3 | + | ^^^^ | |
| 4 | +conform/err/StmtNest.raz:5:5: error: expected "begin", found "end" | |
| 5 | + 5 | end; | |
| 6 | + | ^ | |
| 7 | +raz: 2 errors |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/StmtNoModule.raz:2:8: error: can't find module Nothing | |
| 2 | + 2 | import Nothing; | |
| 3 | + | ^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/StmtNotStmt.raz:6:5: error: a value isn't a statement | |
| 2 | + 6 | r.a; | |
| 3 | + | ^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/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,10 @@ | ||
| 1 | +conform/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 | +conform/err/StmtSigForward.raz:2:6: note: the signature is here | |
| 5 | + 2 | proc f(a: I64); forward; | |
| 6 | + | ^ | |
| 7 | +conform/err/StmtSigForward.raz:4:19: error: f is declared forward but never defined | |
| 8 | + 4 | end StmtSigForward. | |
| 9 | + | ^ | |
| 10 | +raz: 2 errors |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/StmtStatement.raz:5:13: error: expected a statement, found ")" | |
| 2 | + 5 | a := 1; ) | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/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,4 @@ | ||
| 1 | +conform/err/mods/StmtOther.raz:1:8: error: expected module StmtOther, found StmtWrong | |
| 2 | + 1 | module StmtWrong; | |
| 3 | + | ^^^^^^^^^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/TildeBool.raz:5:11: error: "~" needs an integer, found BOOL | |
| 2 | + 5 | b := ~b; | |
| 3 | + | ^ | |
| 4 | +help: a BOOL is negated with not | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/Tuple.raz:6:10: error: two returns several results | |
| 2 | + 6 | a := two() + 1; | |
| 3 | + | ^^^^^ | |
| 4 | +help: they go to variables: a, b := two(...) | |
| 5 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/TwoTypes.raz:6:10: error: can't use List(I32).List as List(I64).List | |
| 2 | + 6 | a := b; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/Utf.raz:2:5: error: only ASCII outside strings, characters and comments | |
| 2 | + 2 | var é: I64; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/Volatile.raz:6:10: error: can't use ^VOLATILE I64 as ^I64 | |
| 2 | + 6 | q := p; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,5 @@ | ||
| 1 | +conform/err/XorBools.raz:5:10: error: "xor" needs integers, found BOOL | |
| 2 | + 5 | b := b xor true; | |
| 3 | + | ^ | |
| 4 | +help: BOOLs that differ are # | |
| 5 | +raz: 1 error |
| @@ -1,5 +0,0 @@ | ||
| 1 | -1001000 | |
| 2 | -1001000 | |
| 3 | -7 | |
| 4 | -10100 | |
| 5 | -nil again 0 |
| @@ -1,66 +0,0 @@ | ||
| 1 | -module Alloc; | |
| 2 | -import Out, Mem, Arena, Heap; | |
| 3 | - | |
| 4 | -type | |
| 5 | - Node = record next: ^Node; val: I64; pad: [5]I64; end; | |
| 6 | - Big = record data: [1000]I64; end; | |
| 7 | - | |
| 8 | -proc build(a: ^Mem.Allocator; n: I64): ^Node; | |
| 9 | -var head, p: ^Node; i: I64; | |
| 10 | -begin | |
| 11 | - head := nil; | |
| 12 | - for i := 1 to n do | |
| 13 | - NEW(p, a); | |
| 14 | - if p = nil then return nil; end; | |
| 15 | - if p^.val # 0 then Out.str("not zeroed "); end; | |
| 16 | - p^.val := i; | |
| 17 | - p^.pad[4] := i; | |
| 18 | - p^.next := head; | |
| 19 | - head := p; | |
| 20 | - end; | |
| 21 | - return head; | |
| 22 | -end; | |
| 23 | - | |
| 24 | -proc sum(p: ^Node): I64; | |
| 25 | -var s: I64; | |
| 26 | -begin | |
| 27 | - s := 0; | |
| 28 | - while p # nil do s := s + p^.val + p^.pad[4]; p := p^.next; end; | |
| 29 | - return s; | |
| 30 | -end; | |
| 31 | - | |
| 32 | -proc release(a: ^Mem.Allocator; p: ^Node); | |
| 33 | -var next: ^Node; | |
| 34 | -begin | |
| 35 | - while p # nil do | |
| 36 | - next := p^.next; | |
| 37 | - Mem.free(a, ^U8(p)); | |
| 38 | - p := next; | |
| 39 | - end; | |
| 40 | -end; | |
| 41 | - | |
| 42 | -proc main*; | |
| 43 | -var ar: Arena.Arena; l, m: ^Node; b: ^Big; i: I64; small: ^U8; again: ^Node; | |
| 44 | -begin | |
| 45 | - l := build(Heap.heap, 1000); | |
| 46 | - Out.int(sum(l)); Out.ln; | |
| 47 | - release(Heap.heap, l); | |
| 48 | - m := build(Heap.heap, 1000); | |
| 49 | - Out.int(sum(m)); Out.ln; | |
| 50 | - NEW(b, Heap.heap); | |
| 51 | - b^.data[999] := 7; | |
| 52 | - Out.int(b^.data[999] + b^.data[0]); Out.ln; | |
| 53 | - Mem.free(Heap.heap, ^U8(b)); | |
| 54 | - if not Arena.init(ADR(ar), 8192) then Out.str("no arena"); end; | |
| 55 | - l := build(ADR(ar.base), 100); | |
| 56 | - Out.int(sum(l)); Out.ln; | |
| 57 | - l := build(ADR(ar.base), 1000); | |
| 58 | - if l = nil then Out.str("nil "); end; | |
| 59 | - Arena.reset(ADR(ar)); | |
| 60 | - NEW(again, ADR(ar.base)); | |
| 61 | - if again # nil then Out.str("again "); Out.int(again^.val); end; | |
| 62 | - Out.ln; | |
| 63 | - Arena.done(ADR(ar)); | |
| 64 | -end; | |
| 65 | - | |
| 66 | -end Alloc. |
| @@ -1,3 +0,0 @@ | ||
| 1 | -one | |
| 2 | -two words | |
| 3 | -é |
| @@ -1,3 +0,0 @@ | ||
| 1 | -one | |
| 2 | -two words | |
| 3 | -é |
| @@ -1,18 +0,0 @@ | ||
| 1 | -module Args; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -proc main*: I64; | |
| 5 | -var i, n: I64; a: ^^U8; s: ^U8; | |
| 6 | -begin | |
| 7 | - a := ARGV(); | |
| 8 | - for i := 1 to ARGC() - 1 do | |
| 9 | - s := a[i]; | |
| 10 | - n := 0; | |
| 11 | - while s[n] # 0 do n := n + 1; end; | |
| 12 | - Out.str(s[0..n]); | |
| 13 | - Out.ln; | |
| 14 | - end; | |
| 15 | - return ARGC(); | |
| 16 | -end; | |
| 17 | - | |
| 18 | -end Args. |
| @@ -1 +0,0 @@ | ||
| 1 | -4 |
| @@ -1,35 +0,0 @@ | ||
| 1 | -M 32 | |
| 2 | -add 22 | |
| 3 | -sub 12 | |
| 4 | -mul 85 | |
| 5 | -div -3 | |
| 6 | -mod -1 | |
| 7 | -divv -3 | |
| 8 | -modv -2 | |
| 9 | -prec 14 | |
| 10 | -neg -85 | |
| 11 | -u8wrap 44 | |
| 12 | -i8wrap -128 | |
| 13 | -u32wrap 1 | |
| 14 | -u64>i 1 | |
| 15 | -i64< 1 | |
| 16 | -shl 1024 | |
| 17 | -shr -4 | |
| 18 | -ushr 15 | |
| 19 | -and 8 | |
| 20 | -or 15 | |
| 21 | -xor 6 | |
| 22 | -not -1 | |
| 23 | -real 85 | |
| 24 | -trunc -2 | |
| 25 | -nan 0 | |
| 26 | -rlt 1 | |
| 27 | -u64real 18 | |
| 28 | -bool 1 | |
| 29 | -shortcut 1 | |
| 30 | -global 42 | |
| 31 | -char 65 | |
| 32 | -utf8 233 | |
| 33 | -hexconst 255 | |
| 34 | -cut 44 | |
| 35 | -sext -1 |
| @@ -1,74 +0,0 @@ | ||
| 1 | -module Arith; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -const | |
| 5 | - K = 10; | |
| 6 | - M = K * 3 + 2; | |
| 7 | - Big = 0FFFFFFFFFFFFFFFFH; | |
| 8 | - | |
| 9 | -var g: I64; | |
| 10 | - | |
| 11 | -proc show(s: []U8; n: I64); | |
| 12 | -begin | |
| 13 | - Out.str(s); Out.str(" "); Out.int(n); Out.ln; | |
| 14 | -end; | |
| 15 | - | |
| 16 | -proc showb(s: []U8; t: BOOL); | |
| 17 | -begin | |
| 18 | - if t then show(s, 1); else show(s, 0); end; | |
| 19 | -end; | |
| 20 | - | |
| 21 | -proc main*; | |
| 22 | -var a, b: I64; u: U8; i8: I8; w: U32; x: U64; r: F64; t: BOOL; | |
| 23 | -begin | |
| 24 | - show("M", M); | |
| 25 | - a := 17; b := 5; | |
| 26 | - show("add", a + b); | |
| 27 | - show("sub", a - b); | |
| 28 | - show("mul", a * b); | |
| 29 | - show("div", -7 div 2); | |
| 30 | - show("mod", -7 mod 2); | |
| 31 | - show("divv", (0 - a) div b); | |
| 32 | - show("modv", (0 - a) mod b); | |
| 33 | - show("prec", 2 + 3 * 4); | |
| 34 | - show("neg", -a * b); | |
| 35 | - u := 200; | |
| 36 | - u := u + 100; | |
| 37 | - show("u8wrap", I64(u)); | |
| 38 | - i8 := 127; | |
| 39 | - i8 := i8 + 1; | |
| 40 | - show("i8wrap", I64(i8)); | |
| 41 | - w := 0FFFFFFFFH; | |
| 42 | - w := w + 2; | |
| 43 | - show("u32wrap", I64(w)); | |
| 44 | - x := Big; | |
| 45 | - showb("u64>i", x > 5); | |
| 46 | - showb("i64<", -1 < 5); | |
| 47 | - show("shl", 1 shl 10); | |
| 48 | - show("shr", -16 shr 2); | |
| 49 | - show("ushr", I64(U64(-16) shr 60)); | |
| 50 | - show("and", 12 & 10); | |
| 51 | - show("or", 12 | 3); | |
| 52 | - show("xor", 12 xor 10); | |
| 53 | - show("not", ~0); | |
| 54 | - r := F64(a) / 2.0; | |
| 55 | - show("real", I64(r * 10.0)); | |
| 56 | - r := -2.75; | |
| 57 | - show("trunc", I64(r)); | |
| 58 | - showb("nan", 0.0 / 0.0 = 0.0 / 0.0); | |
| 59 | - showb("rlt", 1.5 < 2.5); | |
| 60 | - show("u64real", I64(F64(x) / 1.0E18)); | |
| 61 | - t := (a > 3) and (b < 3); | |
| 62 | - if not t then show("bool", 1); end; | |
| 63 | - t := (a > 3) or (g div 0 = 1); | |
| 64 | - if t then show("shortcut", 1); end; | |
| 65 | - g := 42; | |
| 66 | - show("global", g); | |
| 67 | - show("char", 'A'); | |
| 68 | - show("utf8", 'é'); | |
| 69 | - show("hexconst", 0FFH); | |
| 70 | - show("cut", I64(U8(300))); | |
| 71 | - show("sext", I64(I8(U8(255)))); | |
| 72 | -end; | |
| 73 | - | |
| 74 | -end Arith. |
| @@ -1 +0,0 @@ | ||
| 1 | -TFFTTFTTTTFTTFTFTFTTTTT |
| @@ -1,41 +0,0 @@ | ||
| 1 | -module ArrayEq; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -type Colour = (red, green, blue); | |
| 5 | - | |
| 6 | -proc say(b: BOOL); | |
| 7 | -begin | |
| 8 | - if b then Out.str("T"); else Out.str("F"); end; | |
| 9 | -end; | |
| 10 | - | |
| 11 | -proc main*; | |
| 12 | -var | |
| 13 | - a, b: [4]I64; s: []I64; e: []I64; | |
| 14 | - w: [3]U16; c, d: [2]Colour; f: [3]BOOL; | |
| 15 | - m, n: [2]set of Colour; p, q: [2]^I64; x: I64; | |
| 16 | - t: [5]U8; | |
| 17 | -begin | |
| 18 | - a := [1, 2, 3, 4]; b := [1, 2, 3, 4]; | |
| 19 | - say(a = b); say(a # b); | |
| 20 | - b[3] := 5; | |
| 21 | - say(a = b); say(a # b); | |
| 22 | - s := a[0..3]; | |
| 23 | - say(s = a[0..3]); say(s = a); (* of different lengths *) | |
| 24 | - say(a[1..1] = e); say(e = s[0..0]); (* empty *) | |
| 25 | - w := [1, 256, 65535]; | |
| 26 | - say(w = [U16(1), 256, 65535]); say(w[2..3] = [U16(65535)]); | |
| 27 | - c := [red, blue]; d := [red, green]; | |
| 28 | - say(c = d); d[1] := blue; say(c = d); | |
| 29 | - f := [true, false, true]; | |
| 30 | - say(f[0..1] = f[2..3]); say(f[0..1] = [true, false]); | |
| 31 | - m := [{red}, {green, blue}]; n := m; | |
| 32 | - say(m = n); n[1] := {blue}; say(m = n); | |
| 33 | - p := [ADR(x), nil]; q := p; | |
| 34 | - say(p = q); q[1] := ADR(x); say(p = q); | |
| 35 | - t := [104, 101, 108, 108, 111]; | |
| 36 | - say(t = "hello"); say("hello" = t[0..5]); say("hell" = t[0..4]); | |
| 37 | - say("help" # t[0..4]); say("" = t[0..0]); | |
| 38 | - Out.ln; | |
| 39 | -end; | |
| 40 | - | |
| 41 | -end ArrayEq. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -12 refused | |
| 2 | -main ends | |
| 3 | -third | |
| 4 | -second, which exits again | |
| 5 | -first |
| @@ -1,41 +0,0 @@ | ||
| 1 | -(* Rt.exit runs what Rt.atExit registered, the last first, each once, | |
| 2 | - then ends the program with main's status. *) | |
| 3 | -module AtExit; | |
| 4 | -import Out, Rt; | |
| 5 | - | |
| 6 | -proc first; | |
| 7 | -begin | |
| 8 | - Out.str("first\n"); | |
| 9 | -end; | |
| 10 | - | |
| 11 | -proc second; | |
| 12 | -begin | |
| 13 | - Out.str("second, which exits again\n"); | |
| 14 | - Rt.exit(5); (* the rest still run, once each; the status is now 5 *) | |
| 15 | -end; | |
| 16 | - | |
| 17 | -proc third; | |
| 18 | -begin | |
| 19 | - Out.str("third\n"); | |
| 20 | -end; | |
| 21 | - | |
| 22 | -proc nothing; | |
| 23 | -begin | |
| 24 | -end; | |
| 25 | - | |
| 26 | -proc main*: I64; | |
| 27 | -var i, full: I64; | |
| 28 | -begin | |
| 29 | - Rt.atExit(first); | |
| 30 | - Rt.atExit(second); | |
| 31 | - Rt.atExit(third); | |
| 32 | - full := 0; | |
| 33 | - for i := 1 to 40 do | |
| 34 | - if Rt.atExit(nothing) = Rt.Full then INC(full); end; | |
| 35 | - end; | |
| 36 | - Out.int(full); Out.str(" refused\n"); | |
| 37 | - Out.str("main ends\n"); | |
| 38 | - return 3; | |
| 39 | -end; | |
| 40 | - | |
| 41 | -end AtExit. |
| @@ -1 +0,0 @@ | ||
| 1 | -5 |
| @@ -1 +0,0 @@ | ||
| 1 | -First Second Bodies main 12 |
| @@ -1,11 +0,0 @@ | ||
| 1 | -module Bodies; | |
| 2 | -import Out, A := First, Second; | |
| 3 | - | |
| 4 | -proc main*; | |
| 5 | -begin | |
| 6 | - Out.str("main "); Out.int(A.count); Out.int(Second.count); Out.ln; | |
| 7 | -end; | |
| 8 | - | |
| 9 | -begin | |
| 10 | - Out.str("Bodies "); | |
| 11 | -end Bodies. |
| @@ -1 +0,0 @@ | ||
| 1 | -0123 | |
| \ No newline at end of file |
| @@ -1,13 +0,0 @@ | ||
| 1 | -module Bounds; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -proc main*; | |
| 5 | -var a: [4]I64; i: I64; | |
| 6 | -begin | |
| 7 | - for i := 0 to 4 do | |
| 8 | - a[i] := i; | |
| 9 | - Out.int(a[i]); | |
| 10 | - end; | |
| 11 | -end; | |
| 12 | - | |
| 13 | -end Bounds. |
| @@ -1 +0,0 @@ | ||
| 1 | -2 |
| @@ -1 +0,0 @@ | ||
| 1 | -test/run/Bounds.raz:8:11: index 4 is out of range for a length of 4 |
| @@ -1,8 +0,0 @@ | ||
| 1 | -12345 | |
| 2 | -10 7 4 1 | |
| 3 | -0 4 8 | |
| 4 | -6 | |
| 5 | -3 | |
| 6 | -0 1 10 11 20 21 | |
| 7 | -4 | |
| 8 | -one two three many |
| @@ -1,42 +0,0 @@ | ||
| 1 | -module Control; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -proc main*; | |
| 5 | -var i, j, n: I64; u: U8; k: I8; | |
| 6 | -begin | |
| 7 | - for i := 1 to 5 do Out.int(i); end; Out.ln; | |
| 8 | - for i := 10 to 1 by -3 do Out.int(i); Out.str(" "); end; Out.ln; | |
| 9 | - for i := 0 to 10 by 4 do Out.int(i); Out.str(" "); end; Out.ln; | |
| 10 | - for i := 5 to 1 do Out.str("never"); end; | |
| 11 | - n := 0; | |
| 12 | - for u := 250 to 255 do n := n + 1; end; | |
| 13 | - Out.int(n); Out.ln; | |
| 14 | - n := 0; | |
| 15 | - for k := 120 to 127 by 3 do n := n + 1; end; | |
| 16 | - Out.int(n); Out.ln; | |
| 17 | - i := 0; | |
| 18 | - while i < 3 do | |
| 19 | - j := 0; | |
| 20 | - while true do | |
| 21 | - if j = 2 then break; end; | |
| 22 | - Out.int(i * 10 + j); Out.str(" "); | |
| 23 | - j := j + 1; | |
| 24 | - end; | |
| 25 | - i := i + 1; | |
| 26 | - end; | |
| 27 | - Out.ln; | |
| 28 | - i := 0; | |
| 29 | - repeat i := i + 1; if i = 4 then break; end; until i = 10; | |
| 30 | - Out.int(i); Out.ln; | |
| 31 | - for i := 1 to 4 do | |
| 32 | - if i = 1 then Out.str("one"); | |
| 33 | - elsif i = 2 then Out.str("two"); | |
| 34 | - elsif i = 3 then Out.str("three"); | |
| 35 | - else Out.str("many"); | |
| 36 | - end; | |
| 37 | - Out.str(" "); | |
| 38 | - end; | |
| 39 | - Out.ln; | |
| 40 | -end; | |
| 41 | - | |
| 42 | -end Control. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -body body done | |
| 2 | -()30 | |
| 3 | -56 | |
| 4 | -[...*][...+**] | |
| 5 | -0 |
| @@ -1,71 +0,0 @@ | ||
| 1 | -module Defers; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -type Pair = record a, b: I64; end; | |
| 5 | - | |
| 6 | -var depth: I64; | |
| 7 | - | |
| 8 | -proc enter(s: []U8); | |
| 9 | -begin | |
| 10 | - Out.str(s); INC(depth); | |
| 11 | -end; | |
| 12 | - | |
| 13 | -proc leave(s: []U8); | |
| 14 | -begin | |
| 15 | - Out.str(s); DEC(depth); | |
| 16 | -end; | |
| 17 | - | |
| 18 | -proc real(x: F64): F64; | |
| 19 | -begin | |
| 20 | - enter("("); | |
| 21 | - defer leave(")"); | |
| 22 | - return x * 2.0; | |
| 23 | -end; | |
| 24 | - | |
| 25 | -proc pair(n: I64): Pair; | |
| 26 | -var p: Pair; | |
| 27 | -begin | |
| 28 | - defer p.a := 99; | |
| 29 | - p.a := n; p.b := n + 1; | |
| 30 | - return p; | |
| 31 | -end; | |
| 32 | - | |
| 33 | -proc begin_end(i: I64); | |
| 34 | -var k: I64; | |
| 35 | -begin | |
| 36 | - defer for k := 1 to i do Out.str("*"); end; | |
| 37 | - if i = 1 then return; end; | |
| 38 | - Out.str("+"); | |
| 39 | -end; | |
| 40 | - | |
| 41 | -proc nested; | |
| 42 | -var i, j: I64; | |
| 43 | -begin | |
| 44 | - for i := 1 to 2 do | |
| 45 | - enter("["); | |
| 46 | - defer leave("]"); | |
| 47 | - defer begin_end(i); | |
| 48 | - j := 0; | |
| 49 | - while true do | |
| 50 | - defer Out.str("."); | |
| 51 | - INC(j); | |
| 52 | - if j = 3 then break; end; | |
| 53 | - end; | |
| 54 | - end; | |
| 55 | -end; | |
| 56 | - | |
| 57 | -proc main*; | |
| 58 | -var p: Pair; | |
| 59 | -begin | |
| 60 | - Out.int(I64(real(1.5) * 10.0)); Out.ln; | |
| 61 | - p := pair(5); | |
| 62 | - Out.int(p.a); Out.int(p.b); Out.ln; | |
| 63 | - nested; | |
| 64 | - Out.ln; | |
| 65 | - Out.int(depth); Out.ln; | |
| 66 | -end; | |
| 67 | - | |
| 68 | -begin | |
| 69 | - defer Out.str("body done\n"); | |
| 70 | - Out.str("body "); | |
| 71 | -end Defers. |
| @@ -1,6 +0,0 @@ | ||
| 1 | -an instance of Loud, of size 1 | |
| 2 | -an empty list | |
| 3 | -in main, Ones has size 1 | |
| 4 | -sky not red | |
| 5 | -rose red | |
| 6 | -grass - |
| @@ -1,34 +0,0 @@ | ||
| 1 | -module FirstUse; | |
| 2 | -import Out, Str, Heap, Table := Map([]U8, Colour, Str.hash, Str.eq), | |
| 3 | - Ints := List(I64), More := List(I64), Never := Loud(I64), Ones := Loud(U8); | |
| 4 | - | |
| 5 | -type Colour = (red, green, blue); | |
| 6 | - | |
| 7 | -var names: Table.Map; (* Table is made here, after Colour *) | |
| 8 | - | |
| 9 | -proc show(k: []U8); | |
| 10 | -var c: Colour; found: BOOL; | |
| 11 | -begin | |
| 12 | - c, found := Table.get(ADR(names), k); | |
| 13 | - Out.str(k); | |
| 14 | - if not found then Out.str(" -"); elsif c = red then Out.str(" red"); else Out.str(" not red"); end; | |
| 15 | - Out.ln; | |
| 16 | -end; | |
| 17 | - | |
| 18 | -(* Ones is first used in a procedure, and made before its code *) | |
| 19 | -proc main*; | |
| 20 | -var a: Ints.List; b: More.List; | |
| 21 | -begin | |
| 22 | - a := b; (* two imports, one instance *) | |
| 23 | - if a.head = nil then Out.str("an empty list\n"); end; | |
| 24 | - Out.str("in main, Ones has size "); Out.int(Ones.size); Out.ln; | |
| 25 | - show("sky"); | |
| 26 | - show("rose"); | |
| 27 | - show("grass"); | |
| 28 | -end; | |
| 29 | - | |
| 30 | -begin | |
| 31 | - Table.init(ADR(names), Heap.heap); | |
| 32 | - Table.put(ADR(names), "rose", red); | |
| 33 | - Table.put(ADR(names), "sky", blue); | |
| 34 | -end FirstUse. |
| @@ -1,6 +0,0 @@ | ||
| 1 | -8 2 true | |
| 2 | -8 1 | |
| 3 | -abtrue | |
| 4 | -[] false | |
| 5 | -157 152 -1 | |
| 6 | -{ BEEF } x18446744073709551615 |
| @@ -1,30 +0,0 @@ | ||
| 1 | -module Generic; | |
| 2 | -import Fmt, Buf, Str, Heap, Stack, Ints := List(I64), More := List(I64), Strs := List([]U8); | |
| 3 | - | |
| 4 | -proc twice(x: I64): I64; begin return x * 2; end; | |
| 5 | - | |
| 6 | -proc main*; | |
| 7 | -var l: Strs.List; v: I64; s: []U8; ok: BOOL; b: Buf.Buf; n: ^Ints.Node; | |
| 8 | -begin | |
| 9 | - ok := Ints.push(ADR(Stack.s), 7); | |
| 10 | - ok := More.push(ADR(Stack.s), 8); | |
| 11 | - Fmt.print("{} {} {}\n", [Fmt.int(Stack.top()), Fmt.int(Stack.s.len), Fmt.bool(ok)]); | |
| 12 | - n := Stack.s.head; | |
| 13 | - v, ok := Ints.pop(ADR(Stack.s)); | |
| 14 | - Fmt.print("{} {}\n", [Fmt.int(v), Fmt.int(Stack.s.len)]); | |
| 15 | - Strs.init(ADR(l), Heap.heap); | |
| 16 | - ok := Strs.push(ADR(l), "b"); | |
| 17 | - ok := Strs.push(ADR(l), "a"); | |
| 18 | - s, ok := Strs.pop(ADR(l)); | |
| 19 | - Fmt.print("{}{}{}\n", [Fmt.str(s), Fmt.str(l.head^.val), Fmt.bool(ok)]); | |
| 20 | - s, ok := Strs.pop(ADR(l)); | |
| 21 | - s, ok := Strs.pop(ADR(l)); | |
| 22 | - Fmt.print("[{}] {}\n", [Fmt.str(s), Fmt.bool(ok)]); | |
| 23 | - Buf.init(ADR(b), Heap.heap); | |
| 24 | - for v := 1 to 40 do Fmt.write(ADR(b), "{},", [Fmt.int(v * v)]); end; | |
| 25 | - Fmt.print("{} {} {}\n", [Fmt.int(b.len), Fmt.int(Str.find(Buf.bytes(ADR(b)), "1600")), Fmt.int(Str.cmp("ab", "b"))]); | |
| 26 | - Buf.done(ADR(b)); | |
| 27 | - Fmt.print("{{ {} }} {}{}\n", [Fmt.hex(48879), Fmt.char('x'), Fmt.uint(0FFFFFFFFFFFFFFFFH)]); | |
| 28 | -end; | |
| 29 | - | |
| 30 | -end Generic. |
| @@ -1,10 +0,0 @@ | ||
| 1 | -nil | |
| 2 | -nil | |
| 3 | -nil | |
| 4 | -nil | |
| 5 | -nil | |
| 6 | -nil | |
| 7 | -a block | |
| 8 | -aligned | |
| 9 | -a block | |
| 10 | -freeing it again |
| @@ -1,34 +0,0 @@ | ||
| 1 | -(* The heap refuses bad sizes and alignments, and stops the program | |
| 2 | - when a block is freed twice. *) | |
| 3 | -module HeapCheck; | |
| 4 | -import Out, Heap, Mem; | |
| 5 | - | |
| 6 | -proc show(p: ^U8); | |
| 7 | -begin | |
| 8 | - if p = nil then Out.str("nil\n"); else Out.str("a block\n"); end; | |
| 9 | -end; | |
| 10 | - | |
| 11 | -proc main*; | |
| 12 | -var p, q: ^U8; | |
| 13 | -begin | |
| 14 | - show(Mem.alloc(Heap.heap, -1, 8)); | |
| 15 | - show(Mem.alloc(Heap.heap, 1 shl 60, 8)); | |
| 16 | - show(Mem.alloc(Heap.heap, 7FFFFFFFFFFFFFF0H, 8)); | |
| 17 | - show(Mem.alloc(Heap.heap, 10, 3)); | |
| 18 | - show(Mem.alloc(Heap.heap, 10, 0)); | |
| 19 | - show(Mem.alloc(Heap.heap, 10, 8192)); | |
| 20 | - p := Mem.alloc(Heap.heap, 10, 64); | |
| 21 | - show(p); | |
| 22 | - if I64(p) mod 64 = 0 then Out.str("aligned\n"); end; | |
| 23 | - Mem.free(Heap.heap, p); | |
| 24 | - q := Mem.alloc(Heap.heap, 100000, 8); | |
| 25 | - show(q); | |
| 26 | - Mem.free(Heap.heap, q); | |
| 27 | - p := Mem.alloc(Heap.heap, 24, 8); | |
| 28 | - Mem.free(Heap.heap, p); | |
| 29 | - Out.str("freeing it again\n"); | |
| 30 | - Mem.free(Heap.heap, p); | |
| 31 | - Out.str("not reached\n"); | |
| 32 | -end; | |
| 33 | - | |
| 34 | -end HeapCheck. |
| @@ -1 +0,0 @@ | ||
| 1 | -2 |
| @@ -1 +0,0 @@ | ||
| 1 | -freeing a stray pointer |
| @@ -1,14 +0,0 @@ | ||
| 1 | -(* Freeing what the heap never gave out stops the program. *) | |
| 2 | -module HeapStray; | |
| 3 | -import Out, Heap, Mem; | |
| 4 | - | |
| 5 | -var a: [4]I64; | |
| 6 | - | |
| 7 | -proc main*; | |
| 8 | -begin | |
| 9 | - Out.str("freeing a stray pointer\n"); | |
| 10 | - Mem.free(Heap.heap, ^U8(ADR(a[2]))); | |
| 11 | - Out.str("not reached\n"); | |
| 12 | -end; | |
| 13 | - | |
| 14 | -end HeapStray. |
| @@ -1 +0,0 @@ | ||
| 1 | -2 |
| @@ -1,8 +0,0 @@ | ||
| 1 | -023 2 0 in out sub sup ne eq | |
| 2 | -13 10 1 2 lt green other | |
| 3 | -120 0 2 | |
| 4 | -47mid | |
| 5 | -24 | |
| 6 | -50 LLCBA | |
| 7 | --1 LLDBA | |
| 8 | -3 | |
| \ No newline at end of file |
| @@ -1,95 +0,0 @@ | ||
| 1 | -module Kinds; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -type | |
| 5 | - Color* = (red, green, blue, black); | |
| 6 | - Colors* = set of Color; | |
| 7 | - Cell = record ch: U8; attr: U8; fg: Color; end; | |
| 8 | - Point = record x, y: I64; name: []U8; end; | |
| 9 | - Line = record a, b: Point; end; | |
| 10 | - | |
| 11 | -var log: [8]U8; nlog: I64; | |
| 12 | - | |
| 13 | -proc note(c: U8); | |
| 14 | -begin | |
| 15 | - log[nlog] := c; | |
| 16 | - INC(nlog); | |
| 17 | -end; | |
| 18 | - | |
| 19 | -proc show(s: Colors); | |
| 20 | -var c: Color; | |
| 21 | -begin | |
| 22 | - for c := red to black do | |
| 23 | - if c in s then Out.int(I64(c)); end; | |
| 24 | - end; | |
| 25 | - Out.str(" "); | |
| 26 | -end; | |
| 27 | - | |
| 28 | -proc name(c: Color): []U8; | |
| 29 | -begin | |
| 30 | - match c of | |
| 31 | - | red: return "red"; | |
| 32 | - | green: return "green"; | |
| 33 | - | else: return "other"; | |
| 34 | - end; | |
| 35 | -end; | |
| 36 | - | |
| 37 | -proc deferred(n: I64): I64; | |
| 38 | -var i: I64; | |
| 39 | -begin | |
| 40 | - defer note('A'); | |
| 41 | - defer note('B'); | |
| 42 | - for i := 1 to 3 do | |
| 43 | - defer note('L'); | |
| 44 | - if i = 2 then break; end; | |
| 45 | - end; | |
| 46 | - if n > 0 then | |
| 47 | - defer note('C'); | |
| 48 | - return n * 10; | |
| 49 | - end; | |
| 50 | - note('D'); | |
| 51 | - return -1; | |
| 52 | -end; | |
| 53 | - | |
| 54 | -proc mid(a, b: Point): Point; | |
| 55 | -begin | |
| 56 | - return {x: (a.x + b.x) div 2, y: (a.y + b.y) div 2, name: "mid"}; | |
| 57 | -end; | |
| 58 | - | |
| 59 | -proc main*; | |
| 60 | -var s, t: Colors; c: Color; cell: Cell; p: Point; l: Line; r: I64; one: Colors; | |
| 61 | -begin | |
| 62 | - s := {red, blue}; | |
| 63 | - t := {blue, black}; | |
| 64 | - show(s + t); show(s * t); show(s - t); show({}); | |
| 65 | - if red in s then Out.str("in "); end; | |
| 66 | - if not (green in s) then Out.str("out "); end; | |
| 67 | - if s * t <= t then Out.str("sub "); end; | |
| 68 | - if s + t >= s then Out.str("sup "); end; | |
| 69 | - if s # t then Out.str("ne "); end; | |
| 70 | - if s = {blue, red} then Out.str("eq"); end; | |
| 71 | - Out.ln; | |
| 72 | - c := green; | |
| 73 | - one := {c, black}; | |
| 74 | - show(one); | |
| 75 | - Out.int(I64(U8(one))); Out.str(" "); | |
| 76 | - Out.int(SIZE(Colors)); Out.str(" "); | |
| 77 | - Out.int(I64(Color(2))); Out.str(" "); | |
| 78 | - if c < blue then Out.str("lt "); end; | |
| 79 | - Out.str(name(c)); Out.str(" "); Out.str(name(black)); Out.ln; | |
| 80 | - cell := {ch: 'x', fg: blue}; | |
| 81 | - Out.int(I64(cell.ch)); Out.str(" "); Out.int(I64(cell.attr)); Out.str(" "); Out.int(I64(cell.fg)); Out.ln; | |
| 82 | - p := mid({x: 2, y: 4}, {y: 10, x: 6}); | |
| 83 | - Out.int(p.x); Out.int(p.y); Out.str(p.name); Out.ln; | |
| 84 | - l := {a: {x: 1, y: 2}, b: p}; | |
| 85 | - Out.int(l.a.y); Out.int(l.b.x); Out.ln; | |
| 86 | - r := deferred(5); | |
| 87 | - Out.int(r); Out.str(" "); Out.str(log[0..nlog]); Out.ln; | |
| 88 | - nlog := 0; | |
| 89 | - r := deferred(0); | |
| 90 | - Out.int(r); Out.str(" "); Out.str(log[0..nlog]); Out.ln; | |
| 91 | - Out.int(I64(Color(I64(c) + 2))); | |
| 92 | - c := Color(nlog); | |
| 93 | -end; | |
| 94 | - | |
| 95 | -end Kinds. |
| @@ -1 +0,0 @@ | ||
| 1 | -2 |
| @@ -1 +0,0 @@ | ||
| 1 | -test/run/Kinds.raz:92:16: 5 isn't a position of Color |
| @@ -1,2 +0,0 @@ | ||
| 1 | -341 entries, 341 of them, summing 6658308 | |
| 2 | -walked 341, summing 6658308 |
| @@ -1,56 +0,0 @@ | ||
| 1 | -(* Map's remove and next, against an array that holds the same: keys | |
| 2 | - hashed into runs of eight, so that removing moves entries back, | |
| 3 | - around the end of the slots too. *) | |
| 4 | -module MapRemove; | |
| 5 | -import Fmt, Heap, Rt, Ints := Map(I64, I64, near, same); | |
| 6 | - | |
| 7 | -const N = 500; | |
| 8 | - | |
| 9 | -proc near(k: I64): U64; | |
| 10 | -begin | |
| 11 | - return U64(k div 8 * 977); | |
| 12 | -end; | |
| 13 | - | |
| 14 | -proc same(a, b: I64): BOOL; | |
| 15 | -begin | |
| 16 | - return a = b; | |
| 17 | -end; | |
| 18 | - | |
| 19 | -proc main*; | |
| 20 | -var | |
| 21 | - m: Ints.Map; want: [N]I64; i, k, v, n, sum, seed: I64; | |
| 22 | - found, _ok: BOOL; | |
| 23 | -begin | |
| 24 | - Ints.init(ADR(m), Heap.heap); | |
| 25 | - seed := 1; | |
| 26 | - for i := 1 to 20000 do | |
| 27 | - seed := (seed * 1103515245 + 12345) & 7FFFFFFFH; | |
| 28 | - k := seed mod N; | |
| 29 | - if seed div N mod 3 = 0 then | |
| 30 | - if Ints.remove(ADR(m), k) # (want[k] # 0) then Rt.stop("remove: wrong answer"); end; | |
| 31 | - want[k] := 0; | |
| 32 | - else | |
| 33 | - _ok := Ints.put(ADR(m), k, i); | |
| 34 | - want[k] := i; | |
| 35 | - end; | |
| 36 | - end; | |
| 37 | - for k := 0 to N - 1 do | |
| 38 | - v, found := Ints.get(ADR(m), k); | |
| 39 | - if (found # (want[k] # 0)) or (v # want[k]) then Rt.stop("get: not what was put"); end; | |
| 40 | - if found then INC(n); INC(sum, v); end; | |
| 41 | - end; | |
| 42 | - if Ints.remove(ADR(m), N) then Rt.stop("remove: a key never put"); end; | |
| 43 | - Fmt.print("{} entries, {} of them, summing {}\n", [Fmt.int(m.len), Fmt.int(n), Fmt.int(sum)]); | |
| 44 | - (* the walk sees each entry once *) | |
| 45 | - n := 0; sum := 0; | |
| 46 | - i, k, v := Ints.next(ADR(m), 0); | |
| 47 | - while i >= 0 do | |
| 48 | - if want[k] # v then Rt.stop("next: not what was put"); end; | |
| 49 | - want[k] := 0; | |
| 50 | - INC(n); INC(sum, v); | |
| 51 | - i, k, v := Ints.next(ADR(m), i); | |
| 52 | - end; | |
| 53 | - Fmt.print("walked {}, summing {}\n", [Fmt.int(n), Fmt.int(sum)]); | |
| 54 | -end; | |
| 55 | - | |
| 56 | -end MapRemove. |
| @@ -1,2 +0,0 @@ | ||
| 1 | -14 7 DEADBEF0 -5 9 | |
| 2 | -240 |
| @@ -1,23 +0,0 @@ | ||
| 1 | -module PackedFields; | |
| 2 | -(* A packed record's fields are read and written wherever they sit *) | |
| 3 | -import Out; | |
| 4 | - | |
| 5 | -type | |
| 6 | - Header = packed record kind: U8; len: U32; big: I64; tag: U8; end; | |
| 7 | - | |
| 8 | -proc main*; | |
| 9 | -var h, g: Header; b: ^U8; | |
| 10 | -begin | |
| 11 | - h.kind := 7; h.len := 0DEADBEEFH; h.big := -5; h.tag := 9; | |
| 12 | - INC(h.len); | |
| 13 | - g := h; | |
| 14 | - Out.int(SIZE(Header)); Out.str(" "); | |
| 15 | - Out.int(I64(g.kind)); Out.str(" "); | |
| 16 | - Out.hex(U64(g.len), 8); Out.str(" "); | |
| 17 | - Out.int(g.big); Out.str(" "); | |
| 18 | - Out.int(I64(g.tag)); Out.ln; | |
| 19 | - b := ADR(g.kind); | |
| 20 | - Out.int(I64(b[1])); Out.ln; | |
| 21 | -end; | |
| 22 | - | |
| 23 | -end PackedFields. |
| @@ -1,5 +0,0 @@ | ||
| 1 | -42 | |
| 2 | -2 whole | |
| 3 | -2 part | |
| 4 | -3 part | |
| 5 | -65 66 67 -65 |
| @@ -1,42 +0,0 @@ | ||
| 1 | -module PassOn; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -type Pair = record a, b: I64; end; | |
| 5 | - | |
| 6 | -proc one(n: I64): I64; | |
| 7 | -begin | |
| 8 | - return n * 2; | |
| 9 | -end; | |
| 10 | - | |
| 11 | -proc two(n: I64): (I64, BOOL); | |
| 12 | -begin | |
| 13 | - return n div 7, n mod 7 = 0; | |
| 14 | -end; | |
| 15 | - | |
| 16 | -proc three(n: I64): (U8, Pair, I64); | |
| 17 | -begin | |
| 18 | - return U8(n), {a: n + 1, b: n + 2}, -n; | |
| 19 | -end; | |
| 20 | - | |
| 21 | -(* each passes on what the one below returns *) | |
| 22 | -proc one1(n: I64): I64; begin return one(n); end; | |
| 23 | -proc one2(n: I64): I64; begin return one1(n); end; | |
| 24 | -proc two1(n: I64): (I64, BOOL); begin return two(n + 1); end; | |
| 25 | -proc two2(n: I64): (I64, BOOL); begin return two1(n + 1); end; | |
| 26 | -proc three1(n: I64): (U8, Pair, I64); begin return three(n); end; | |
| 27 | -proc three2(n: I64): (U8, Pair, I64); begin return three1(n); end; | |
| 28 | - | |
| 29 | -proc main*; | |
| 30 | -var i, q: I64; z: BOOL; c: U8; p: Pair; | |
| 31 | -begin | |
| 32 | - Out.int(one2(21)); Out.ln; | |
| 33 | - for i := 0 to 2 do | |
| 34 | - q, z := two2(i * 5 + 12); | |
| 35 | - Out.int(q); Out.str(" "); if z then Out.str("whole"); else Out.str("part"); end; Out.ln; | |
| 36 | - end; | |
| 37 | - c, p, i := three2(65); | |
| 38 | - Out.int(I64(c)); Out.str(" "); Out.int(p.a); Out.str(" "); Out.int(p.b); | |
| 39 | - Out.str(" "); Out.int(i); Out.ln; | |
| 40 | -end; | |
| 41 | - | |
| 42 | -end PassOn. |
| @@ -1,2 +0,0 @@ | ||
| 1 | --7 div 2 = -3, -7 mod 2 = -1 | |
| 2 | -0 wrong |
| @@ -1,68 +0,0 @@ | ||
| 1 | -(* div, mod and * by a power of two are shifts; they must agree with | |
| 2 | - idiv and imul, which a divisor in a variable still gets. *) | |
| 3 | -module Pow2; | |
| 4 | -import Out; | |
| 5 | - | |
| 6 | -var bad: I64; | |
| 7 | - | |
| 8 | -proc check(s: []U8; x, got, want: I64); | |
| 9 | -begin | |
| 10 | - if got # want then | |
| 11 | - Out.str(s); Out.str(" "); Out.int(x); Out.str(": "); | |
| 12 | - Out.int(got); Out.str(" # "); Out.int(want); Out.ln; | |
| 13 | - bad := bad + 1; | |
| 14 | - end; | |
| 15 | -end; | |
| 16 | - | |
| 17 | -proc i64s(x: I64); | |
| 18 | -var d1, d2, d8, d62: I64; | |
| 19 | -begin | |
| 20 | - d1 := 1; d2 := 2; d8 := 8; d62 := 4000000000000000H; | |
| 21 | - check("div 1", x, x div 1, x div d1); | |
| 22 | - check("mod 1", x, x mod 1, x mod d1); | |
| 23 | - check("div 2", x, x div 2, x div d2); | |
| 24 | - check("mod 2", x, x mod 2, x mod d2); | |
| 25 | - check("div 8", x, x div 8, x div d8); | |
| 26 | - check("mod 8", x, x mod 8, x mod d8); | |
| 27 | - check("div 2^62", x, x div 4000000000000000H, x div d62); | |
| 28 | - check("mod 2^62", x, x mod 4000000000000000H, x mod d62); | |
| 29 | - check("* 8", x, x * 8, x * d8); | |
| 30 | - check("div -8", x, x div (0 - 8), x div (0 - d8)); | |
| 31 | -end; | |
| 32 | - | |
| 33 | -proc u64s(x: U64); | |
| 34 | -var d2, d8, d62: U64; | |
| 35 | -begin | |
| 36 | - d2 := 2; d8 := 8; d62 := 4000000000000000H; | |
| 37 | - check("u div 2", I64(x), I64(x div 2), I64(x div d2)); | |
| 38 | - check("u mod 2", I64(x), I64(x mod 2), I64(x mod d2)); | |
| 39 | - check("u div 8", I64(x), I64(x div 8), I64(x div d8)); | |
| 40 | - check("u mod 8", I64(x), I64(x mod 8), I64(x mod d8)); | |
| 41 | - check("u div 2^62", I64(x), I64(x div 4000000000000000H), I64(x div d62)); | |
| 42 | - check("u mod 2^62", I64(x), I64(x mod 4000000000000000H), I64(x mod d62)); | |
| 43 | -end; | |
| 44 | - | |
| 45 | -proc main*; | |
| 46 | -var i: I64; b: I8; d: I8; w: U8; dw: U8; | |
| 47 | -begin | |
| 48 | - for i := -300 to 300 do i64s(i); u64s(U64(i)); end; | |
| 49 | - i64s(07FFFFFFFFFFFFFFFH); i64s(-07FFFFFFFFFFFFFFFH - 1); | |
| 50 | - i64s(4000000000000001H); i64s(-4000000000000001H); | |
| 51 | - u64s(0FFFFFFFFFFFFFFFFH); u64s(8000000000000000H); | |
| 52 | - d := 8; dw := 8; | |
| 53 | - for i := -128 to 127 do | |
| 54 | - b := I8(i); w := U8(i + 128); | |
| 55 | - check("i8 div 8", i, I64(b div 8), I64(b div d)); | |
| 56 | - check("i8 mod 8", i, I64(b mod 8), I64(b mod d)); | |
| 57 | - check("i8 * 8", i, I64(b * 8), I64(b * d)); | |
| 58 | - check("u8 div 8", i, I64(w div 8), I64(w div dw)); | |
| 59 | - check("u8 mod 8", i, I64(w mod 8), I64(w mod dw)); | |
| 60 | - check("u8 * 8", i, I64(w * 8), I64(w * dw)); | |
| 61 | - end; | |
| 62 | - i := -7; | |
| 63 | - Out.str("-7 div 2 = "); Out.int(i div 2); | |
| 64 | - Out.str(", -7 mod 2 = "); Out.int(i mod 2); Out.ln; | |
| 65 | - Out.int(bad); Out.str(" wrong\n"); | |
| 66 | -end; | |
| 67 | - | |
| 68 | -end Pow2. |
| @@ -1,13 +0,0 @@ | ||
| 1 | -parity ok | |
| 2 | -21 | |
| 3 | -10 11 21 | |
| 4 | -22 | |
| 5 | -7 12 | |
| 6 | -same | |
| 7 | -nil | |
| 8 | -3245 | |
| 9 | -2432902008176640000 | |
| 10 | -95 5 | |
| 11 | -0 | |
| 12 | -16 0 | |
| 13 | -15 |
| @@ -1,117 +0,0 @@ | ||
| 1 | -module Procs; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -type | |
| 5 | - Pair = record x, y: I64; end; | |
| 6 | - Op = proc(a, b: I64): I64; | |
| 7 | - Big = record a: [10]I64; end; | |
| 8 | - | |
| 9 | -proc even(n: I64): BOOL; forward; | |
| 10 | - | |
| 11 | -proc odd(n: I64): BOOL; | |
| 12 | -begin | |
| 13 | - if n = 0 then return false; end; | |
| 14 | - return even(n - 1); | |
| 15 | -end; | |
| 16 | - | |
| 17 | -proc even(n: I64): BOOL; | |
| 18 | -begin | |
| 19 | - if n = 0 then return true; end; | |
| 20 | - return odd(n - 1); | |
| 21 | -end; | |
| 22 | - | |
| 23 | -proc swap(var a, b: I64); | |
| 24 | -var t: I64; | |
| 25 | -begin | |
| 26 | - t := a; a := b; b := t; | |
| 27 | -end; | |
| 28 | - | |
| 29 | -proc bump(p: Pair): Pair; | |
| 30 | -begin | |
| 31 | - p.x := p.x + 1; | |
| 32 | - p.y := p.y + 1; | |
| 33 | - return p; | |
| 34 | -end; | |
| 35 | - | |
| 36 | -proc add(a, b: I64): I64; begin return a + b; end; | |
| 37 | -proc mul(a, b: I64): I64; begin return a * b; end; | |
| 38 | - | |
| 39 | -proc apply(f: Op; a, b: I64): I64; | |
| 40 | -begin | |
| 41 | - return f(a, b); | |
| 42 | -end; | |
| 43 | - | |
| 44 | -proc many(a, b, c, d, e, f, g, h: I64; x: F64; i: I64; y: F64): I64; | |
| 45 | -begin | |
| 46 | - return a + 2 * b + 3 * c + 4 * d + 5 * e + 6 * f + 7 * g + 8 * h + I64(x) * 100 + 9 * i + I64(y) * 1000; | |
| 47 | -end; | |
| 48 | - | |
| 49 | -proc fact(n: I64): I64; | |
| 50 | -begin | |
| 51 | - if n <= 1 then return 1; end; | |
| 52 | - return n * fact(n - 1); | |
| 53 | -end; | |
| 54 | - | |
| 55 | -proc fill(var b: Big; v: I64); | |
| 56 | -var i: I64; | |
| 57 | -begin | |
| 58 | - for i := 0 to 9 do b.a[i] := v + i; end; | |
| 59 | -end; | |
| 60 | - | |
| 61 | -proc total(b: Big): I64; | |
| 62 | -var i, s: I64; | |
| 63 | -begin | |
| 64 | - s := 0; | |
| 65 | - for i := 0 to 9 do s := s + b.a[i]; end; | |
| 66 | - b.a[0] := 1000; | |
| 67 | - return s; | |
| 68 | -end; | |
| 69 | - | |
| 70 | -proc noresult(n: I64): I64; | |
| 71 | -begin | |
| 72 | - if n > 100 then return 1; end; | |
| 73 | -end; | |
| 74 | - | |
| 75 | -proc mk(n: I64): Big; | |
| 76 | -var b: Big; | |
| 77 | -begin | |
| 78 | - fill(b, n); | |
| 79 | - return b; | |
| 80 | -end; | |
| 81 | - | |
| 82 | -proc mkzero(n: I64): Big; | |
| 83 | -begin | |
| 84 | -end; | |
| 85 | - | |
| 86 | -proc fsum(a, b: F64): F64; | |
| 87 | -begin | |
| 88 | - return a + b; | |
| 89 | -end; | |
| 90 | - | |
| 91 | -proc main*: I64; | |
| 92 | -var a, b: I64; p, q: Pair; f: Op; bg: Big; | |
| 93 | -begin | |
| 94 | - if even(10) and odd(7) and not even(3) then Out.str("parity ok"); Out.ln; end; | |
| 95 | - a := 1; b := 2; | |
| 96 | - swap(a, b); | |
| 97 | - Out.int(a); Out.int(b); Out.ln; | |
| 98 | - p.x := 10; p.y := 20; | |
| 99 | - q := bump(p); | |
| 100 | - Out.int(p.x); Out.str(" "); Out.int(q.x); Out.str(" "); Out.int(q.y); Out.ln; | |
| 101 | - Out.int(bump(bump(p)).y); Out.ln; | |
| 102 | - f := add; | |
| 103 | - Out.int(apply(f, 3, 4)); Out.str(" "); Out.int(apply(mul, 3, 4)); Out.ln; | |
| 104 | - if f = add then Out.str("same"); Out.ln; end; | |
| 105 | - f := nil; | |
| 106 | - if f = nil then Out.str("nil"); Out.ln; end; | |
| 107 | - Out.int(many(1, 1, 1, 1, 1, 1, 1, 1, 2.5, 1, 3.9)); Out.ln; | |
| 108 | - Out.int(fact(20)); Out.ln; | |
| 109 | - fill(bg, 5); | |
| 110 | - Out.int(total(bg)); Out.str(" "); Out.int(bg.a[0]); Out.ln; | |
| 111 | - Out.int(noresult(5)); Out.ln; | |
| 112 | - Out.int(mk(7).a[9]); Out.str(" "); Out.int(mkzero(1).a[3]); Out.ln; | |
| 113 | - Out.int(I64(fsum(1.25, 2.5) * 4.0)); Out.ln; | |
| 114 | - return 7; | |
| 115 | -end; | |
| 116 | - | |
| 117 | -end Procs. |
| @@ -1 +0,0 @@ | ||
| 1 | -7 |
| @@ -1,12 +0,0 @@ | ||
| 1 | -7506AC5B262CA1FF | |
| 2 | -3FB999999999999A | |
| 3 | -FFFFFFFFFFFFF | |
| 4 | -1 | |
| 5 | -1 | |
| 6 | -0 | |
| 7 | -0 | |
| 8 | -7FEFFFFFFFFFFFFF | |
| 9 | -4340000000000000 | |
| 10 | -4340000000000002 | |
| 11 | -3FF0000000000000 | |
| 12 | -3FF0000000000001 |
| @@ -1,34 +0,0 @@ | ||
| 1 | -(* Real literals read to the nearest F64, ties to the even one: their | |
| 2 | - bits, for numbers a reader of decimals easily gets one off. *) | |
| 3 | -module RealRead; | |
| 4 | -import Fmt; | |
| 5 | - | |
| 6 | -proc bits(x: F64): U64; | |
| 7 | -var p: ^U64; | |
| 8 | -begin | |
| 9 | - p := ^U64(ADR(x)); | |
| 10 | - return p^; | |
| 11 | -end; | |
| 12 | - | |
| 13 | -proc show(x: F64); | |
| 14 | -begin | |
| 15 | - Fmt.print("{}\n", [Fmt.hex(bits(x))]); | |
| 16 | -end; | |
| 17 | - | |
| 18 | -proc main*; | |
| 19 | -begin | |
| 20 | - show(5.319372648326541E255); | |
| 21 | - show(0.1); | |
| 22 | - show(2.2250738585072011E-308); (* just below the least normal *) | |
| 23 | - show(4.9E-324); (* the least F64 *) | |
| 24 | - show(2.4703282292062328E-324); (* just over half of it: up *) | |
| 25 | - show(2.4703282292062327E-324); (* just under: 0 *) | |
| 26 | - show(1.0E-400); | |
| 27 | - show(1.7976931348623157E308); (* the largest *) | |
| 28 | - show(9007199254740993.0); (* 2^53 + 1, a tie: down to even *) | |
| 29 | - show(9007199254740995.0); (* 2^53 + 3, a tie: up to even *) | |
| 30 | - show(1.00000000000000011102230246251565404236316680908203125); (* 1 + 2^-53, a tie *) | |
| 31 | - show(1.00000000000000011102230246251565404236316680908203126); | |
| 32 | -end; | |
| 33 | - | |
| 34 | -end RealRead. |
| @@ -1 +0,0 @@ | ||
| 1 | -6 3 0 | |
| \ No newline at end of file |
| @@ -1,15 +0,0 @@ | ||
| 1 | -module SliceBounds; | |
| 2 | -(* A slice must have 0 <= lo <= hi <= the length *) | |
| 3 | -import Out; | |
| 4 | - | |
| 5 | -proc main*; | |
| 6 | -var a: [8]I64; s: []I64; lo: I64; | |
| 7 | -begin | |
| 8 | - s := a[0..8]; | |
| 9 | - for lo := 0 to 9 by 3 do | |
| 10 | - Out.int(LEN(s[lo..6])); | |
| 11 | - Out.str(" "); | |
| 12 | - end; | |
| 13 | -end; | |
| 14 | - | |
| 15 | -end SliceBounds. |
| @@ -1 +0,0 @@ | ||
| 1 | -2 |
| @@ -1 +0,0 @@ | ||
| 1 | -test/run/SliceBounds.raz:10:23: slice 9..6 is out of range for a length of 8 |
| @@ -1 +0,0 @@ | ||
| 1 | -0123 | |
| \ No newline at end of file |
| @@ -1,15 +0,0 @@ | ||
| 1 | -module SliceIndex; | |
| 2 | -(* An index checked against a slice's length, which is in memory *) | |
| 3 | -import Out; | |
| 4 | - | |
| 5 | -proc main*; | |
| 6 | -var a: [8]I64; s: []I64; i: I64; | |
| 7 | -begin | |
| 8 | - s := a[2..5]; | |
| 9 | - for i := 0 to 3 do | |
| 10 | - Out.int(i); | |
| 11 | - s[i] := i; | |
| 12 | - end; | |
| 13 | -end; | |
| 14 | - | |
| 15 | -end SliceIndex. |
| @@ -1 +0,0 @@ | ||
| 1 | -2 |
| @@ -1 +0,0 @@ | ||
| 1 | -test/run/SliceIndex.raz:11:11: index 3 is out of range for a length of 3 |
| @@ -1 +0,0 @@ | ||
| 1 | -2 0 | |
| \ No newline at end of file |
| @@ -1,16 +0,0 @@ | ||
| 1 | -module SlicePtrBackwards; | |
| 2 | -(* A slice of a pointer isn't checked against a length, but it can't | |
| 3 | - run backwards *) | |
| 4 | -import Out; | |
| 5 | - | |
| 6 | -proc main*; | |
| 7 | -var a: [8]U8; p: ^U8; hi: I64; | |
| 8 | -begin | |
| 9 | - p := ADR(a[0]); | |
| 10 | - for hi := 4 to 0 by -2 do | |
| 11 | - Out.int(LEN(p[2..hi])); | |
| 12 | - Out.str(" "); | |
| 13 | - end; | |
| 14 | -end; | |
| 15 | - | |
| 16 | -end SlicePtrBackwards. |
| @@ -1 +0,0 @@ | ||
| 1 | -2 |
| @@ -1 +0,0 @@ | ||
| 1 | -test/run/SlicePtrBackwards.raz:11:23: slice 2..0 runs backwards |
| @@ -1,4 +0,0 @@ | ||
| 1 | -Bo 7 | |
| 2 | -Di 23 | |
| 3 | -Ana 41 | |
| 4 | -Cy 90 |
| @@ -1,51 +0,0 @@ | ||
| 1 | -(* Sort: slices in many orders and of every length up to 40 come out | |
| 2 | - in order, holding what they held; and a sort by a record's field. *) | |
| 3 | -module Sorted; | |
| 4 | -import Fmt, Rt, Ints := Sort(I64, below), ByAge := Sort(Person, younger); | |
| 5 | - | |
| 6 | -type Person = record name: []U8; age: I64; end; | |
| 7 | - | |
| 8 | -proc below(a, b: I64): BOOL; | |
| 9 | -begin | |
| 10 | - return a < b; | |
| 11 | -end; | |
| 12 | - | |
| 13 | -proc younger(a, b: Person): BOOL; | |
| 14 | -begin | |
| 15 | - return a.age < b.age; | |
| 16 | -end; | |
| 17 | - | |
| 18 | -proc main*; | |
| 19 | -var | |
| 20 | - a: [40]I64; count: [10]I64; n, i, kind, seed: I64; | |
| 21 | - people: [4]Person; | |
| 22 | -begin | |
| 23 | - seed := 7; | |
| 24 | - for n := 0 to 40 do | |
| 25 | - for kind := 0 to 3 do | |
| 26 | - for i := 0 to 9 do count[i] := 0; end; | |
| 27 | - for i := 0 to n - 1 do | |
| 28 | - seed := (seed * 1103515245 + 12345) & 7FFFFFFFH; | |
| 29 | - if kind = 0 then a[i] := seed mod 10; (* at random, with repeats *) | |
| 30 | - elsif kind = 1 then a[i] := i mod 10; (* rising *) | |
| 31 | - elsif kind = 2 then a[i] := 9 - i mod 10; (* falling *) | |
| 32 | - else a[i] := 5; (* all equal *) | |
| 33 | - end; | |
| 34 | - INC(count[a[i]]); | |
| 35 | - end; | |
| 36 | - Ints.sort(a[0..n]); | |
| 37 | - for i := 0 to n - 1 do | |
| 38 | - if (i > 0) and (a[i - 1] > a[i]) then Rt.stop("out of order"); end; | |
| 39 | - DEC(count[a[i]]); | |
| 40 | - end; | |
| 41 | - for i := 0 to 9 do | |
| 42 | - if count[i] # 0 then Rt.stop("not what it held"); end; | |
| 43 | - end; | |
| 44 | - end; | |
| 45 | - end; | |
| 46 | - people := [{name: "Ana", age: 41}, {name: "Bo", age: 7}, {name: "Cy", age: 90}, {name: "Di", age: 23}]; | |
| 47 | - ByAge.sort(people); | |
| 48 | - for i := 0 to 3 do Fmt.print("{} {}\n", [Fmt.str(people[i].name), Fmt.int(people[i].age)]); end; | |
| 49 | -end; | |
| 50 | - | |
| 51 | -end Sorted. |
| @@ -1,4 +0,0 @@ | ||
| 1 | -eq ne lit arr buf 0 5 2 | |
| 2 | -6 100 0 | |
| 3 | -threeone | |
| 4 | -é☺A |
| @@ -1,39 +0,0 @@ | ||
| 1 | -module Strings; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -const greeting = "hello"; | |
| 5 | - | |
| 6 | -var buf: [8]U8; | |
| 7 | - | |
| 8 | -proc count(xs: []I64): I64; | |
| 9 | -var i, s: I64; | |
| 10 | -begin | |
| 11 | - s := 0; | |
| 12 | - for i := 0 to LEN(xs) - 1 do s := s + xs[i]; end; | |
| 13 | - return s; | |
| 14 | -end; | |
| 15 | - | |
| 16 | -proc main*; | |
| 17 | -var a: []U8; b: [5]U8; c: [3]I64; d: [][]U8; | |
| 18 | -begin | |
| 19 | - a := "hello"; | |
| 20 | - if a = greeting then Out.str("eq "); end; | |
| 21 | - if a # "help" then Out.str("ne "); end; | |
| 22 | - if "abc" = "abc" then Out.str("lit "); end; | |
| 23 | - b := "hello"; | |
| 24 | - if b = a then Out.str("arr "); end; | |
| 25 | - buf := "hi"; | |
| 26 | - if buf[0..2] = "hi" then Out.str("buf "); end; | |
| 27 | - Out.int(I64(buf[5])); Out.str(" "); | |
| 28 | - Out.int(LEN(greeting)); Out.str(" "); | |
| 29 | - Out.int(LEN(a[1..3])); Out.ln; | |
| 30 | - c := [1, 2, 3]; | |
| 31 | - Out.int(count(c)); Out.str(" "); | |
| 32 | - Out.int(count([10, 20, 30, 40])); Out.str(" "); | |
| 33 | - Out.int(count([])); Out.ln; | |
| 34 | - d := ["one", "two", "three"]; | |
| 35 | - Out.str(d[2]); Out.str(d[0]); Out.ln; | |
| 36 | - Out.str("é\u{263A}\x41\n"); | |
| 37 | -end; | |
| 38 | - | |
| 39 | -end Strings. |
| @@ -1,14 +0,0 @@ | ||
| 1 | -module First; | |
| 2 | -import Out; | |
| 3 | - | |
| 4 | -var count*: I64; | |
| 5 | - | |
| 6 | -proc main*; | |
| 7 | -begin | |
| 8 | - Out.str("First.main must not run"); | |
| 9 | -end; | |
| 10 | - | |
| 11 | -begin | |
| 12 | - count := 1; | |
| 13 | - Out.str("First "); | |
| 14 | -end First. |
| @@ -1,10 +0,0 @@ | ||
| 1 | -(* A generic module with a body, which runs once for each instance *) | |
| 2 | -module Loud(T); | |
| 3 | -import Out; | |
| 4 | - | |
| 5 | -var size*: I64; | |
| 6 | - | |
| 7 | -begin | |
| 8 | - size := SIZE(T); | |
| 9 | - Out.str("an instance of Loud, of size "); Out.int(size); Out.ln; | |
| 10 | -end Loud. |
| @@ -1,11 +0,0 @@ | ||
| 1 | -module Second; | |
| 2 | -import Out, First; | |
| 3 | - | |
| 4 | -var count*: I64; | |
| 5 | - | |
| 6 | -begin | |
| 7 | - count := First.count + 1; | |
| 8 | - Out.str("Second "); | |
| 9 | - if count = 2 then return; end; | |
| 10 | - Out.str("not reached"); | |
| 11 | -end Second. |
| @@ -1,13 +0,0 @@ | ||
| 1 | -module Stack; | |
| 2 | -import Ints := List(I64), Heap; | |
| 3 | - | |
| 4 | -var s*: Ints.List; | |
| 5 | - | |
| 6 | -proc top*(): I64; | |
| 7 | -begin | |
| 8 | - return s.head^.val; | |
| 9 | -end; | |
| 10 | - | |
| 11 | -begin | |
| 12 | - Ints.init(ADR(s), Heap.heap); | |
| 13 | -end Stack. |