diff --git a/src/MatchImpl.jl b/src/MatchImpl.jl index b98520e..0084131 100644 --- a/src/MatchImpl.jl +++ b/src/MatchImpl.jl @@ -18,7 +18,7 @@ function pattern_unref end function pattern_unmacrocall(macro_func, self::Function, args::AbstractArray) @sswitch args begin @case [ln, m::Module, args...] - return self(macro_func(ln, m, args...)) + return self(macroexpand(m, Expr(:macrocall, macro_func, ln, args...))) end end diff --git a/src/Pervasives.jl b/src/Pervasives.jl index ecf7faf..fbcccaa 100644 --- a/src/Pervasives.jl +++ b/src/Pervasives.jl @@ -31,13 +31,13 @@ function MLStyle.pattern_uncall( targs::AbstractArray, args::AbstractArray, ) - isempty(tparams) || error("A (:) pattern requires no type params.") - isempty(targs) || error("A (:) pattern requires no type arguments.") + isempty(tparams) || return begin - call = Expr(:call, t, args...) - ann = Expr(:curly, t, targs...) + call = Expr(:call, Dict, args...) + ann = Expr(:curly, Dict, targs...) self(Where(call, ann, tparams)) end + pairs = Pair[] for arg in args @switch arg begin diff --git a/test/issues/109.jl b/test/issues/109.jl index 9511969..d8d798b 100644 --- a/test/issues/109.jl +++ b/test/issues/109.jl @@ -1,4 +1,21 @@ -@test 20 == @match raw"123" begin - r"\Gaaa$" => 10 - raw"123" => 20 +@testcase "#109: matching macrocall" begin + @test 20 == @match raw"123" begin + r"\Gaaa$" => 10 + raw"123" => 20 + end + + @lift @as_record struct Name + n + end + + @lift macro some_macro() + n = esc(:Name) + :(Name($n)) + end + + f(Name) = @match Name begin + @some_macro() => Name + end + + @test f(Name(1)) == 1 end diff --git a/test/runtests.jl b/test/runtests.jl index dd8d1f7..60e3727 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -52,6 +52,7 @@ MODULE = TestModule @use GADT +include("issues/109.jl") include("when.jl") include("untyped_lam.jl") include("active_patterns.jl") @@ -78,6 +79,5 @@ include("MQuery/test.jl") include("issues/87.jl") include("issues/62.jl") -include("issues/109.jl") end