summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-12-05 10:58:18 +0100
committerAraq <rumpf_a@web.de>2018-12-05 10:58:18 +0100
commitaf815c3c1830db313491ffeb33a54c35fdde371e (patch)
treea6ac87987c91abaebe6f8233019517913a74cb78 /tests
parent24106ade8fee790fcfbab17d6c7825d79e05c7f3 (diff)
downloadNim-af815c3c1830db313491ffeb33a54c35fdde371e.tar.gz
fixes #9864 [backport]
Diffstat (limited to 'tests')
-rw-r--r--tests/macros/tescape_var_into_quotedo_as_const.nim36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/macros/tescape_var_into_quotedo_as_const.nim b/tests/macros/tescape_var_into_quotedo_as_const.nim
new file mode 100644
index 000000000..1ed93f012
--- /dev/null
+++ b/tests/macros/tescape_var_into_quotedo_as_const.nim
@@ -0,0 +1,36 @@
+discard """
+  output: '''ok'''
+"""
+# bug #9864
+import macros, tables
+
+proc bar(shOpt: Table[string, int]) = discard
+
+macro dispatchGen(): untyped =
+  var shOpt = initTable[string, int]()
+  shOpt["foo"] = 10
+  result = quote do:
+     bar(`shOpt`)
+
+dispatchGen()
+
+type
+  Foo = object
+    data: seq[int]
+
+proc barB(a: Foo) = discard
+
+proc shOptB(): auto =
+  var shOpt: Foo
+  shOpt.data.setLen 1 # fails
+  shOpt
+
+macro dispatchGenB(): untyped =
+  var shOpt = shOptB() # fails
+
+  result = quote do:
+     barB(`shOpt`)
+
+dispatchGenB()
+
+echo "ok"