summary refs log tree commit diff stats
path: root/lib/core/macros.nim
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2018-09-17 18:10:05 +0300
committerzah <zahary@gmail.com>2018-09-17 22:17:39 +0300
commit95072fbcc3379a3dfa2356f6c1ed1bfad5b6a656 (patch)
treecea079c80862c2569ea071ce0c7bed3eab71b7e1 /lib/core/macros.nim
parent34388c5cc5a3fc92d4cb94d815671b483295ba54 (diff)
downloadNim-95072fbcc3379a3dfa2356f6c1ed1bfad5b6a656.tar.gz
Bugfix: custom pragmas were not working on public fields
Diffstat (limited to 'lib/core/macros.nim')
-rw-r--r--lib/core/macros.nim13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index aec766068..0ac46b54d 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -1321,7 +1321,7 @@ proc customPragmaNode(n: NimNode): NimNode =
       return typ.getImpl()[0][1]
 
   if n.kind in {nnkDotExpr, nnkCheckedFieldExpr}:
-    let name = (if n.kind == nnkCheckedFieldExpr: n[0][1] else: n[1])
+    let name = $(if n.kind == nnkCheckedFieldExpr: n[0][1] else: n[1])
     var typDef = getImpl(getTypeInst(if n.kind == nnkCheckedFieldExpr or n[0].kind == nnkHiddenDeref: n[0][0] else: n[0]))
     while typDef != nil:
       typDef.expectKind(nnkTypeDef)
@@ -1349,9 +1349,14 @@ proc customPragmaNode(n: NimNode): NimNode =
 
           else:
             for i in 0 .. identDefs.len - 3:
-              if identDefs[i].kind == nnkPragmaExpr and
-                identDefs[i][0].kind == nnkIdent and $identDefs[i][0] == $name:
-                return identDefs[i][1]
+              let varNode = identDefs[i]
+              if varNode.kind == nnkPragmaExpr:
+                var varName = varNode[0]
+                if varName.kind == nnkPostfix:
+                  # This is a public field. We are skipping the postfix *
+                  varName = varName[1]
+                if eqIdent(varName.strVal, name):
+                  return identDefs[i][1]
 
         if obj[1].kind == nnkOfInherit: # explore the parent object
           typDef = getImpl(obj[1][0])