summary refs log tree commit diff stats
path: root/tests/template
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-03-13 22:29:48 +0100
committerAraq <rumpf_a@web.de>2014-03-13 22:29:48 +0100
commit3e056afb1c481d35403c93bc17307b46be5e20f2 (patch)
tree997aeee1899a13d4a7014d4713252eaf27effd2f /tests/template
parent1c35fb3c89bbac393b50c4bc6fe8205af2b7fb9d (diff)
downloadNim-3e056afb1c481d35403c93bc17307b46be5e20f2.tar.gz
fixes #993
Diffstat (limited to 'tests/template')
-rw-r--r--tests/template/tissue993.nim21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/template/tissue993.nim b/tests/template/tissue993.nim
new file mode 100644
index 000000000..d39f43942
--- /dev/null
+++ b/tests/template/tissue993.nim
@@ -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)
+