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

Patterns with getproperty access broke in v2.0.0 #90

Open
jonniediegelman opened this issue Aug 4, 2023 · 1 comment
Open

Patterns with getproperty access broke in v2.0.0 #90

jonniediegelman opened this issue Aug 4, 2023 · 1 comment

Comments

@jonniediegelman
Copy link

The 2.0 update broke patterns that look like a.b. Having these patterns is useful for working with EnumX enums because they have to be accessed through their generated module.

With Match@1.2.0:

julia> using EnumX, Match

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
0

With Match@2.0.0:

julia> using EnumX, Match

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: REPL[5]:2: Unrecognized pattern syntax `Fruit.APPLE`.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] bind_pattern!(location::LineNumberNode, source::Expr, input::Symbol, binder::Match.BinderContext, assigned::Base.ImmutableDict{Symbol, Symbol})
   @ Match ~/.julia/packages/Match/SZDEk/src/binding.jl:408
 [3] bind_case(case_number::Int64, location::LineNumberNode, case::Expr, predeclared_temps::Vector{Any}, binder::Match.BinderContext)
   @ Match ~/.julia/packages/Match/SZDEk/src/binding.jl:580
 [4] build_automaton_core(value::Symbol, source_cases::Vector{Any}, location::LineNumberNode, predeclared_temps::Vector{Any}, binder::Match.BinderContext)
   @ Match ~/.julia/packages/Match/SZDEk/src/match_cases_opt.jl:15
 [5] build_automaton(location::LineNumberNode, mod::Module, value::Any, body::Expr)
   @ Match ~/.julia/packages/Match/SZDEk/src/match_cases_opt.jl:149
 [6] build_deduplicated_automaton
   @ ~/.julia/packages/Match/SZDEk/src/match_cases_opt.jl:158 [inlined]
 [7] handle_match_cases(location::LineNumberNode, mod::Module, value::Symbol, body::Expr)
   @ Match ~/.julia/packages/Match/SZDEk/src/match_cases_opt.jl:477
 [8] var"@match"(__source__::LineNumberNode, __module__::Module, value::Any, cases::Any)
   @ Match ~/.julia/packages/Match/SZDEk/src/matchmacro.jl:114
in expression starting at REPL[5]:1
@jonniediegelman jonniediegelman changed the title Patterns with getproperty access broke Patterns with getproperty access broke in v2.0.0 Aug 4, 2023
@gafter
Copy link
Member

gafter commented Aug 8, 2023

Please use $(Fruit.APPLE). The escape syntax is used to refer to general expressions or values defined elsewhere.

This was an intentional change in 2.0. I will make sure we document this as a known breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants