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

Match can't match tuple literal #62

Closed
smabie opened this issue Jul 30, 2020 · 1 comment
Closed

Match can't match tuple literal #62

smabie opened this issue Jul 30, 2020 · 1 comment

Comments

@smabie
Copy link

smabie commented Jul 30, 2020

So this works:

x = (3, 5)

@match x begin
    (a, b) => a + b
end

but this doesn't

@match (3, 5) begin
    (a, b) => a + b
end

I get the error:

ERROR: LoadError: MethodError: Cannot `convert` an object of type Int64 to an object of type Union{Expr, Symbol}
Closest candidates are:
  convert(::Type{S}, ::T) where {S, T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)} at /home/sturm/.julia/packages/CategoricalArrays/dmrjI/src/value.jl:103
  convert(::Type{T}, ::Intervals.Interval{T,L,R} where R<:Intervals.Bound where L<:Intervals.Bound) where T at /home/sturm/.julia/packages/Intervals/iTDy5/src/interval.jl:195
  convert(::Type{T}, ::Intervals.AnchoredInterval{P,T,L,R} where R<:Intervals.Bounded where L<:Intervals.Bounded) where {P, T} at /home/sturm/.julia/packages/Intervals/iTDy5/src/anchoredinterval.jl:178
  ...
Stacktrace:
 [1] convert(::Type{Tuple{Union{Expr, Symbol}}}, ::Tuple{Int64}) at ./essentials.jl:307 (repeats 2 times)
 [2] push!(::Array{Tuple{Union{Expr, Symbol},Union{Expr, Symbol}},1}, ::Tuple{Symbol,Int64}) at ./array.jl:868
 [3] unapply(::Int64, ::Symbol, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Match.MatchExprInfo, ::Bool) at /home/sturm/.julia/packages/Match/qiTCM/src/matchmacro.jl:43
 [4] unapply(::Array{Any,1}, ::Array{Any,1}, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Match.MatchExprInfo, ::Bool) at /home/sturm/.julia/packages/Match/qiTCM/src/matchmacro.jl:245
 [5] unapply(::Expr, ::Expr, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Match.MatchExprInfo, ::Bool) at /home/sturm/.julia/packages/Match/qiTCM/src/matchmacro.jl:81
 [6] unapply(::Expr, ::Expr, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Match.MatchExprInfo) at /home/sturm/.julia/packages/Match/qiTCM/src/matchmacro.jl:56
 [7] gen_match_expr(::Expr, ::Expr, ::Symbol, ::Bool) at /home/sturm/.julia/packages/Match/qiTCM/src/matchmacro.jl:367
 [8] gen_match_expr(::Expr, ::Expr, ::Symbol) at /home/sturm/.julia/packages/Match/qiTCM/src/matchmacro.jl:348
 [9] @match(::LineNumberNode, ::Module, ::Any, ::Any) at /home/sturm/.julia/packages/Match/qiTCM/src/matchmacro.jl:434
in expression starting at REPL[112]:1

I assume this is a bug and not intended behavior?

@gafter
Copy link
Member

gafter commented Aug 3, 2023

Fixed in v2:

julia> Pkg.status()
      Status `~/.julia/environments/v1.6/Project.toml`
  [7eb4fadd] Match v2.0.0

julia> @match (3, 5) begin
           (a, b) => a + b
       end
8

@gafter gafter closed this as completed Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants