fixes #993
This commit is contained in:
parent
1c35fb3c89
commit
3e056afb1c
3 changed files with 29 additions and 2 deletions
21
tests/template/tissue993.nim
Normal file
21
tests/template/tissue993.nim
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
type pnode* = ref object of tobject
|
||||
|
||||
template litNode (name, ty): stmt =
|
||||
type name* = ref object of PNode
|
||||
val*: ty
|
||||
litNode PIntNode, int
|
||||
|
||||
import json
|
||||
|
||||
template withKey*(j: PJsonNode; key: string; varname: expr;
|
||||
body:stmt): stmt {.immediate.} =
|
||||
if j.hasKey(key):
|
||||
let varname{.inject.}= j[key]
|
||||
block:
|
||||
body
|
||||
|
||||
var j = parsejson("{\"zzz\":1}")
|
||||
withkey(j, "foo", x):
|
||||
echo(x)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue