import macros
template test(a: bool) =
if a:
echo "true seen"
else:
echo "false seen"
macro joe(body: untyped): untyped =
result = newStmtList()
let temp = getAst test(true)
result.add(temp)
joe:
echo "never seen"
Run
I've been able to narrow down my problem scenario. A template with a bool
parameter works normally except when pulled through getAst inside a macro. In
that scenario, it seems to "become" an integer.
I get the error:
/home/johnad/test.nim(14, 1) template/generic instantiation of `joe` from
here
/home/johnad/test.nim(11, 25) Error: type mismatch: got <int literal(1)>
but expected 'bool'
Run
Am I misusing something? Or is this a bug?