summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorjcosborn <jcosborn@users.noreply.github.com>2019-01-07 05:36:06 -0600
committerAndreas Rumpf <rumpf_a@web.de>2019-01-07 12:36:06 +0100
commit044cef152f6006927a905d69dc527cada8206b0f (patch)
tree95c9baf8e3b88005b00b7787cc8b49496b056a59 /lib
parent139fa396e8fa0e8603d4f53ac90841421e50aa3f (diff)
downloadNim-044cef152f6006927a905d69dc527cada8206b0f.tar.gz
add custom pragma support for var and let symbols (#9582)
* add custom pragma support for var and let symbols
* updated changelog for custom pragmas on var and let symbols
* add oldast switch for backwards compatibility
Diffstat (limited to 'lib')
-rw-r--r--lib/core/macros.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 291858bed..64334161e 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -1402,8 +1402,14 @@ proc customPragmaNode(n: NimNode): NimNode =
     let impl = n.getImpl()
     if impl.kind in RoutineNodes:
       return impl.pragma
+    elif impl.kind == nnkIdentDefs and impl[0].kind == nnkPragmaExpr:
+      return impl[0][1]
     else:
-      return typ.getImpl()[0][1]
+      let timpl = typ.getImpl()
+      if timpl.len>0 and timpl[0].len>1:
+        return timpl[0][1]
+      else:
+        return timpl
 
   if n.kind in {nnkDotExpr, nnkCheckedFieldExpr}:
     let name = $(if n.kind == nnkCheckedFieldExpr: n[0][1] else: n[1])