Skip to content

Commit

Permalink
fix customPragmaNode call for certain objects
Browse files Browse the repository at this point in the history
I'm a little puzzled about this. With the change introduced in the
previous commit to add the `noserialize` option for JSON, the first
example in the `tjsonmacro.nim` does not work anymore. The generic
`Point[float]` cannot be serialized, because of a `node is not a
symbol` error. In order to get the type def implementation under the
given case, we have to also get the implementation of the underlying
type.

Maybe this should be fixed in a different way?
  • Loading branch information
Vindaar committed Jun 5, 2019
1 parent 20acbfd commit 5da931f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/core/macros.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,12 @@ proc customPragmaNode(n: NimNode): NimNode =
if n.kind in {nnkDotExpr, nnkCheckedFieldExpr}:
let name = $(if n.kind == nnkCheckedFieldExpr: n[0][1] else: n[1])
let typInst = getTypeInst(if n.kind == nnkCheckedFieldExpr or n[0].kind == nnkHiddenDeref: n[0][0] else: n[0])
var typDef = getImpl(if typInst.kind == nnkVarTy: typInst[0] else: typInst)
var typDef = getImpl(
if typInst.kind == nnkVarTy or
typInst.kind == nnkBracketExpr:
typInst[0]
else: typInst
)
while typDef != nil:
typDef.expectKind(nnkTypeDef)
let typ = typDef[2]
Expand Down

0 comments on commit 5da931f

Please sign in to comment.