parser change: 'not' is always a unary operator; fixes #9574
This commit is contained in:
parent
b1ad5fd7da
commit
8a357c270b
4 changed files with 11 additions and 1 deletions
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
- The `unchecked` pragma was removed, instead use `system.UncheckedArray`.
|
- The `unchecked` pragma was removed, instead use `system.UncheckedArray`.
|
||||||
- The undocumented ``#? strongSpaces`` parsing mode has been removed.
|
- The undocumented ``#? strongSpaces`` parsing mode has been removed.
|
||||||
|
- The `not` operator is now always a unary operator, this means that code like
|
||||||
|
``assert not isFalse(3)`` compiles.
|
||||||
|
|
||||||
|
|
||||||
#### Breaking changes in the standard library
|
#### Breaking changes in the standard library
|
||||||
|
|
|
||||||
|
|
@ -966,7 +966,7 @@ proc getPrecedence*(tok: TToken, strongSpaces: bool): int =
|
||||||
of '?': result = 2
|
of '?': result = 2
|
||||||
else: considerAsgn(2)
|
else: considerAsgn(2)
|
||||||
of tkDiv, tkMod, tkShl, tkShr: result = 9
|
of tkDiv, tkMod, tkShl, tkShr: result = 9
|
||||||
of tkIn, tkNotin, tkIs, tkIsnot, tkNot, tkOf, tkAs: result = 5
|
of tkIn, tkNotin, tkIs, tkIsnot, tkOf, tkAs: result = 5
|
||||||
of tkDotDot: result = 6
|
of tkDotDot: result = 6
|
||||||
of tkAnd: result = 4
|
of tkAnd: result = 4
|
||||||
of tkOr, tkXor, tkPtr, tkRef: result = 3
|
of tkOr, tkXor, tkPtr, tkRef: result = 3
|
||||||
|
|
|
||||||
|
|
@ -514,6 +514,9 @@ are used for other notational purposes.
|
||||||
``*:`` is as a special case treated as the two tokens `*`:tok: and `:`:tok:
|
``*:`` is as a special case treated as the two tokens `*`:tok: and `:`:tok:
|
||||||
(to support ``var v*: T``).
|
(to support ``var v*: T``).
|
||||||
|
|
||||||
|
The ``not`` keyword is always a unary operator, ``a not b`` is parsed
|
||||||
|
as ``a(not b)``, not as ``(a) not (b)``.
|
||||||
|
|
||||||
|
|
||||||
Other tokens
|
Other tokens
|
||||||
------------
|
------------
|
||||||
|
|
|
||||||
|
|
@ -19,3 +19,8 @@ proc foo[S, T](x: S, y: T): T = x & y
|
||||||
proc bar[T](x: T): T = x
|
proc bar[T](x: T): T = x
|
||||||
|
|
||||||
echo "def".foo[:string, string]("abc"), " ", 4.bar[:int]
|
echo "def".foo[:string, string]("abc"), " ", 4.bar[:int]
|
||||||
|
|
||||||
|
# bug #9574
|
||||||
|
proc isFalse(a: int): bool = false
|
||||||
|
|
||||||
|
assert not isFalse(3)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue