Work with EnumX and other namespaced properties
jonniediegelman opened this issue · 2 comments
jonniediegelman commented
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 commented
Possibly if the case is head: Symbol .
, could we just evaluate directly?