Skip to content

Commit de7d101

Browse files
nigredo-torioprypin
authored andcommitted
Fix equality after method dispatch changes in Nim (#30)
1 parent 6a1570b commit de7d101

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/docopt.nim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,14 @@ method name(self: Pattern): string {.base, gcsafe.} =
9696
method `name=`(self: Pattern, name: string) {.base, gcsafe.} =
9797
self.m_name = name
9898

99-
method `==`(self, other: Pattern): bool {.base, gcsafe, nosideeffect.} =
100-
self.str == other.str
99+
proc `==`(self, other: Pattern): bool =
100+
if self.is_nil and other.is_nil:
101+
true
102+
elif not self.is_nil and not other.is_nil:
103+
self.str == other.str
104+
else:
105+
# Exactly one of the two is nil
106+
false
101107

102108
method flat(self: Pattern,
103109
types: varargs[string]): seq[Pattern] {.base, gcsafe.} =

0 commit comments

Comments
 (0)