Skip to content

Commit

Permalink
skip postfix node when resolving distinct type from impl AST
Browse files Browse the repository at this point in the history
`resolveTypeFromDistinct` calls `getImpl` on the distinct type which yields an `nkTypeDef` node of the original distinct type declaration, and returns the first child of the node, what would normally be the type name.

Normally when a type is exported its name in the AST becomes an `nkPostfix` node, however due to a [Nim bug](nim-lang/Nim#22933) this node was not saved in typed AST and the first child was always the type symbol node. If the bug in Nim is fixed, `resolveTypeFromDistinct` has to skip the postfix node here.
  • Loading branch information
metagn authored and Vindaar committed Dec 20, 2023
1 parent 61f65c5 commit a578232
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/unchained/macro_utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ proc resolveTypeFromDistinct(n: NimNode): NimNode =
let typ = n.getImpl
doAssert typ.kind == nnkTypeDef
result = typ[0]
if result.kind == nnkPostfix: result = result[1]

proc resolveTypeFromTypeDesc(n: NimNode): NimNode =
let typ = n.getType
Expand Down

0 comments on commit a578232

Please sign in to comment.