summary refs log tree commit diff stats
path: root/tests/macros
diff options
context:
space:
mode:
authorClyybber <darkmine956@gmail.com>2020-08-27 15:50:59 +0200
committerGitHub <noreply@github.com>2020-08-27 15:50:59 +0200
commitfb58066b61b14f4a1d6cdb0f4a8f0a9ea4174d82 (patch)
treec6e573d9ac221c786ac9e0ca2cf0f186d87a6bbe /tests/macros
parentd11933ad998fb0a3eb51bbefbaa53e583aaa3ac1 (diff)
downloadNim-fb58066b61b14f4a1d6cdb0f4a8f0a9ea4174d82.tar.gz
Fix #5691 (#15158)
* Fix #5691
* Cleanup and thoughts
* Use scope approach
* Seperate defined/declared/declaredInScope magics
* Fix declaredInScope
* Update spec accordingly
Diffstat (limited to 'tests/macros')
-rw-r--r--tests/macros/tmacros_various.nim15
-rw-r--r--tests/macros/tmacrotypes.nim2
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/macros/tmacros_various.nim b/tests/macros/tmacros_various.nim
index 3cb5aaa8f..64bb7345a 100644
--- a/tests/macros/tmacros_various.nim
+++ b/tests/macros/tmacros_various.nim
@@ -22,6 +22,7 @@ a[1]: 45
 x: some string
 ([("key", "val"), ("keyB", "2")], [("val", "key"), ("2", "keyB")])
 ([("key", "val"), ("keyB", "2")], [("val", "key"), ("2", "keyB")])
+0
 '''
 """
 
@@ -222,3 +223,17 @@ block getImplTransformed:
   doAssert "toExpand" notin code
     # template is expanded (but that would already be the case with
     # `a.getImpl.repr`, unlike the other transformations mentioned above
+
+
+# test macro resemming
+macro makeVar(): untyped =
+  quote:
+    var tensorY {.inject.}: int
+
+macro noop(a: typed): untyped =
+  a
+
+noop:
+  makeVar
+echo tensorY
+
diff --git a/tests/macros/tmacrotypes.nim b/tests/macros/tmacrotypes.nim
index cfc4ef7fb..43819c81d 100644
--- a/tests/macros/tmacrotypes.nim
+++ b/tests/macros/tmacrotypes.nim
@@ -43,6 +43,8 @@ macro checkType(ex: typed): untyped =
   echo ex.getTypeInst.repr, "; ", ex.typeKind, "; ", ex.getType.repr, "; ", ex.getTypeImpl.repr
 
 macro checkProcType(fn: typed): untyped =
+  if fn.kind == nnkProcDef:
+    result = fn
   let fn_sym = if fn.kind == nnkProcDef: fn[0] else: fn
   echo fn_sym, "; ", fn_sym.typeKind, "; ", fn_sym.getType.repr, "; ", fn_sym.getTypeImpl.repr