Case bodies with certain expressions case macro-expansion time crash.
arthurp opened this issue · 1 comments
arthurp commented
@match
crashes during macro expansion when applied to the following code (I'm using released v1.0.1 on Julia v1.0):
@match 1 begin _ => [] end
The error message is:
ERROR: LoadError: MethodError: no method matching union()
Closest candidates are:
union(::Pkg.Pkg2.Pkg2Types.VersionSet, ::Pkg.Pkg2.Pkg2Types.VersionSet) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Pkg2/types.jl:130
union(::Pkg.Types.VersionSpec, ::Pkg.Types.VersionSpec) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/versions.jl:223
union(::BitSet, ::Any...) at bitset.jl:272
...
Stacktrace:
[1] getvars(::Array{Any,1}) at /home/amp/.julia/packages/Match/M8WAy/src/matchutils.jl:76
[2] getvars(::Expr) at /home/amp/.julia/packages/Match/M8WAy/src/matchutils.jl:73
[3] gen_match_expr(::Int64, ::Expr, ::Symbol, ::Bool) at /home/amp/.julia/packages/Match/M8WAy/src/matchmacro.jl:365
[4] gen_match_expr(::Int64, ::Expr, ::Symbol) at /home/amp/.julia/packages/Match/M8WAy/src/matchmacro.jl:348
[5] @match(::LineNumberNode, ::Module, ::Any, ::Any) at /home/amp/.julia/packages/Match/M8WAy/src/matchmacro.jl:434
in expression starting at none:1
It looks like getvars
doesn't correctly handle the case where an Expr
does not have any args
. Specifically it calls union
with one arg per element of args
, so empty args
means zero-arg union
call, which is an error.