SPEC change: ^ is right-assoc and of highest priority

This commit is contained in:
Araq 2011-01-10 21:28:48 +01:00
commit 19fbc8a55e
4 changed files with 38 additions and 26 deletions

View file

@ -49,6 +49,7 @@ tnestprc.nim;10
toop1.nim;34[]o 5
topenarrayrepr.nim;5 - [1]
topenlen.nim;7
toprprec.nim;done
toverflw.nim;the computation overflowed
toverflw2.nim;Error: unhandled exception: over- or underflow [EOverflow]
toverl2.nim;true012

1 tack.nim 125
49 toop1.nim 34[]o 5
50 topenarrayrepr.nim 5 - [1]
51 topenlen.nim 7
52 toprprec.nim done
53 toverflw.nim the computation overflowed
54 toverflw2.nim Error: unhandled exception: over- or underflow [EOverflow]
55 toverl2.nim true012

View file

@ -0,0 +1,12 @@
# Test operator precedence:
assert 3+5*5-2 == 28- -26-28
proc `^-` (x, y: int): int =
# now right-associative!
result = x - y
assert 34 ^- 6 ^- 2 == 30
assert 34 - 6 - 2 == 26
echo "done"