SPEC change: ^ is right-assoc and of highest priority
This commit is contained in:
parent
ceb1f5e218
commit
19fbc8a55e
4 changed files with 38 additions and 26 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
12
tests/accept/run/toprprec.nim
Normal file
12
tests/accept/run/toprprec.nim
Normal 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"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue