-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
This code is mostly self-explanatory, I really don't understand why that error happens :)
Example
import macros
macro test*(): untyped =
let b = @[1, 2, 3, 4]
result = nnkStmtList.newTree()
var i = 0
while i < b.len:
if false:
# this quote do is mandatory, removing it fixes the problem
result.add quote do:
let testtest = 5
else:
result.add quote do:
let test = 6
inc i
# removing this continue fixes the problem too
continue
inc i
test()Current Output
/home/dian/Projects/nim-snippets/tt.nim(14, 7) Error: expression '
add(result, getAst(`:anonymous`(newIdentNode("result"))))
inc i, 1
continue' is of type 'NimNode' and has to be used (or discarded); start of expression here: /home/dian/Projects/nim-snippets/tt.nim(9, 5)
Expected Output
No error
Additional information
Confirmed that it worked in 1.0.6 via the playground.
$ nim -v
Nim Compiler Version 1.3.5 [Linux: amd64]
Compiled at 2020-06-14
Copyright (c) 2006-2020 by Andreas Rumpf
git hash: d749c8cd87508871dc28b528f57d26b1004007b3
active boot switches: -d:release -d:danger
Metadata
Metadata
Assignees
Labels
No labels