Skip to content

Support qualified variant selectors with matching? #83

@deech

Description

@deech

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions