Skip to content

Commit e0dfb9e

Browse files
authored
fix regression caused by caseStmtMacros: match=>case (#73)
1 parent ea18f85 commit e0dfb9e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/fusion/matching.nim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,7 @@ func toNode(
21092109

21102110
macro expand*(body: typed): untyped = body
21112111

2112-
macro match*(n: untyped): untyped =
2112+
proc matchImpl(n: NimNode): NimNode =
21132113
var matchcase = nnkIfStmt.newTree()
21142114
var mixidents: seq[string]
21152115
for elem in n[1 .. ^1]:
@@ -2157,7 +2157,10 @@ macro match*(n: untyped): untyped =
21572157
let pos {.inject, used.}: int = 0
21582158
`matchcase`
21592159

2160-
# echo result.repr
2160+
when (NimMajor, NimMinor, NimPatch) >= (1,5,1):
2161+
macro `case`*(n: untyped): untyped = matchImpl(n)
2162+
else:
2163+
macro match*(n: untyped): untyped = matchImpl(n)
21612164

21622165
macro assertMatch*(input, pattern: untyped): untyped =
21632166
## Try to match `input` using `pattern` and raise `MatchError` on

0 commit comments

Comments
 (0)