This commit is contained in:
Araq
2014-06-30 22:24:08 +02:00
parent b89495ef0f
commit 0339b9d386
2 changed files with 29 additions and 1 deletions

View File

@@ -546,7 +546,7 @@ proc flattenTree(root: PNode): PNode =
flattenTreeAux(result, root, op)
else:
result = root
proc transformCall(c: PTransf, n: PNode): PTransNode =
var n = flattenTree(n)
var op = getMergeOp(n)
@@ -565,6 +565,9 @@ proc transformCall(c: PTransf, n: PNode): PTransNode =
inc(j)
add(result, a.PTransNode)
if len(result) == 2: result = result[1]
elif getMagic(n) == mNBindSym:
# for bindSym(myconst) we MUST NOT perform constant folding:
result = n.PTransNode
else:
let s = transformSons(c, n).PNode
# bugfix: check after 'transformSons' if it's still a method call:

25
tests/macros/tbindsym.nim Normal file
View File

@@ -0,0 +1,25 @@
discard """
output: '''TFoo
TBar'''
"""
# bug #1319
import macros
type
TTextKind = enum
TFoo, TBar
macro test: stmt =
var x = @[TFoo, TBar]
result = newStmtList()
for i in x:
result.add newCall(newIdentNode("echo"),
case i
of TFoo:
bindSym("TFoo")
of TBar:
bindSym("TBar"))
test()