require not nil to be on the same line after a type (#24134)

fixes #23565
This commit is contained in:
metagn
2024-09-18 23:45:19 +03:00
committed by GitHub
parent 0c3573e4a0
commit 00ac961ab1
3 changed files with 14 additions and 1 deletions

View File

@@ -1401,7 +1401,7 @@ proc primary(p: var Parser, mode: PrimaryMode): PNode =
result = primarySuffix(p, result, baseInd, mode)
proc binaryNot(p: var Parser; a: PNode): PNode =
if p.tok.tokType == tkNot:
if p.tok.tokType == tkNot and p.tok.indent < 0:
let notOpr = newIdentNodeP(p.tok.ident, p)
getTok(p)
optInd(p, notOpr)

View File

@@ -0,0 +1,3 @@
type Foo = ref int
not nil #[tt.Error
^ invalid indentation]#

View File

@@ -0,0 +1,10 @@
# issue #23565
func foo: bool =
true
const bar = block:
type T = int
not foo()
doAssert not bar