Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion union.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.2.0"
version = "0.2.1"
author = "Leorize"
description = "Anonymous unions in Nim"
license = "MIT"
Expand Down
11 changes: 11 additions & 0 deletions union/typeutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,24 @@ func newTypedesc*(n: NimNode): NimNode =
## Create a typedesc[n]
nnkBracketExpr.newTree(bindSym"typedesc", copy(n))


proc skipSink(n: NimNode): NimNode =
if n.kind == nnkBracketExpr and n[0].eqIdent"sink":
n[1]
else:
n

func sameType*(a, b: NimNode): bool =
## A variant of sameType to workaround:
##
## * https://github.com/nim-lang/Nim/issues/18867
##
## * https://github.com/nim-lang/Nim/issues/19072

let
a = a.skipSink()
b = b.skipSink()

# XXX: compiler bug workaround; see https://github.com/nim-lang/Nim/issues/18867
if macros.sameType(a, b) or macros.sameType(b, a):
# XXX: compiler bug workaround; see https://github.com/nim-lang/Nim/issues/19072
Expand Down
Loading