-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels

Description
Example
import macros
macro notBug(n: untyped): untyped =
let node = n[0] # skip the nnkStmtList
node[1] = newLit(2) # replace 0 with 2
result = n
macro bug(n: untyped): untyped =
let (node, ) = (n[0], )
node[1] = newLit(2)
# Another version using object:
# type Holder = object
# val: NimNode
# let node = Holder(val: n[0])
# node.val[1] = newLit(2)
result = n
var x = notBug: 0 * 2
var y = bug: 0 * 2
echo x
echo y
Current Output
4
0
Expected Output
4
4
Additional Information
Doesn't seem to be a regression.