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

Work with EnumX and other namespaced properties #185

Open
jonniediegelman opened this issue Feb 27, 2024 · 2 comments
Open

Work with EnumX and other namespaced properties #185

jonniediegelman opened this issue Feb 27, 2024 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@jonniediegelman
Copy link

It would be great if @match worked with enums from EnumX and other similar namespaced items.

julia> using EnumX, MLStyle

julia> @enumx Fruit APPLE BANANA PEAR

julia> fruit = Fruit.APPLE
Fruit.APPLE = 0

julia> @match fruit begin
           Fruit.APPLE => 0
           Fruit.BANANA => 1
           Fruit.PEAR => 2
       end
ERROR: LoadError: PatternCompilationError(:(#= REPL[4]:2 =#), ErrorException("unknown pattern syntax :(Fruit.APPLE)"))
Stacktrace:
 [1] gen_match(val::Symbol, tbl::Expr, __source__::LineNumberNode, __module__::Module)
   @ MLStyle.MatchImpl ~/.julia/packages/MLStyle/SLOsr/src/MatchImpl.jl:712
 [2] var"@match"(__source__::LineNumberNode, __module__::Module, val::Any, tbl::Any)
   @ MLStyle.MatchImpl ~/.julia/packages/MLStyle/SLOsr/src/MatchImpl.jl:667
in expression starting at REPL[4]:1

caused by: unknown pattern syntax :(Fruit.APPLE)
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] ex2tf(m::Module, ex::Expr)
   @ MLStyle.MatchImpl ~/.julia/packages/MLStyle/SLOsr/src/MatchImpl.jl:351
 [3] gen_match(val::Symbol, tbl::Expr, __source__::LineNumberNode, __module__::Module)
   @ MLStyle.MatchImpl ~/.julia/packages/MLStyle/SLOsr/src/MatchImpl.jl:710
 [4] var"@match"(__source__::LineNumberNode, __module__::Module, val::Any, tbl::Any)
   @ MLStyle.MatchImpl ~/.julia/packages/MLStyle/SLOsr/src/MatchImpl.jl:667
@jonniediegelman
Copy link
Author

Possibly if the case is head: Symbol ., could we just evaluate directly?

@thautwarm thautwarm added the enhancement New feature or request label Feb 28, 2024
@thautwarm thautwarm added this to the 0.5 milestone Feb 28, 2024
@thautwarm
Copy link
Owner

This is due to the issue discussed at #156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants