Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #66 by skipping over sink types in the sameType macro #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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