fusion
fusion copied to clipboard
Support qualified variant selectors with matching?
The following fails:
import options
import fusion/matching
{.experimental: "caseStmtMacros".}
type
OKind* = enum O1
O* = object
case kind*: OKind
of O1: o1*: int
case O(kind:O1,o1:1):
of OKind.O1(o1: @i): echo i
with:
nim c --forceBuild:on --gc:orc -r --verbosity\:0 --hint\[Processing\]\:off --excessiveStackTrace\:on /tmp/matchingtest.nim
/tmp/matchingtest.nim(10, 1) template/generic instantiation of `case` from here
/tmp/matchingtest.nim(11, 11) Error: undeclared field: 'O1' for type matchingtest.O [type declared in /tmp/matchingtest.nim(6, 3)]
found 'O1' [enumField declared in /tmp/matchingtest.nim(5, 17)]
nim-compile exited abnormally with code 1 at Sat Mar 27 11:49:16
If I remove the variant qualification it works:
case O(kind:O1,o1:1):
of O1(o1: @i): echo i
I have variant kinds with name clashes so being able to fully qualify the enum selector would be useful.
It would be possible to implement, and I think it should be supported. Most likely this is an implementation oversight on my side.