summary refs log tree commit diff stats
path: root/tests/macros
diff options
context:
space:
mode:
Diffstat (limited to 'tests/macros')
-rw-r--r--tests/macros/macro_bug.nim17
-rw-r--r--tests/macros/tsame_name_497.nim5
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/macros/macro_bug.nim b/tests/macros/macro_bug.nim
new file mode 100644
index 000000000..0d0fa76ac
--- /dev/null
+++ b/tests/macros/macro_bug.nim
@@ -0,0 +1,17 @@
+import macros
+
+macro macro_bug*(s: stmt): stmt {.immediate.} =
+  s.expectKind({nnkProcDef, nnkMethodDef})
+
+  var params = s.params
+
+  let genericParams = s[2]
+  result = newNimNode(nnkProcDef).add(
+    s.name, s[1], genericParams, params, pragma(s), newEmptyNode())
+
+  var body = body(s)
+
+  # Fails here.
+  var call = newCall("macro_bug", s.params[1][0])
+  body.insert(0, call)
+  result.add(body)
diff --git a/tests/macros/tsame_name_497.nim b/tests/macros/tsame_name_497.nim
new file mode 100644
index 000000000..e49f9f6d8
--- /dev/null
+++ b/tests/macros/tsame_name_497.nim
@@ -0,0 +1,5 @@
+import macro_bug
+
+type TObj = object
+
+proc f(o: TObj) {.macro_bug.} = discard