diff --git a/src/utils.jl b/src/utils.jl index b9f6f3f..4c63a49 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -60,10 +60,9 @@ Compare `quote end` vs `rmlines(quote end)` """ rmlines(x) = x function rmlines(x::Expr) - # Do not strip the first argument to a macrocall, which is - # required. - if x.head == :macrocall && length(x.args) >= 2 - Expr(x.head, x.args[1:2]..., filter(x->!isline(x), x.args[3:end])...) + # :macrocall has a LineNumberNode as second argument, which we replace by `nothing` + if x.head == :macrocall && length(x.args) >= 2 && VERSION >= v"0.7" + Expr(x.head, x.args[1], nothing, filter(x->!isline(x), x.args[3:end])...) else Expr(x.head, filter(x->!isline(x), x.args)...) end diff --git a/test/match.jl b/test/match.jl index 23b922f..e59db02 100644 --- a/test/match.jl +++ b/test/match.jl @@ -1,3 +1,9 @@ +@test MacroTools.postwalk(MacroTools.@q (@time 2+2)) do x # issue #107 + @assert !MacroTools.isline(x) + true +end + + let x = @match :(2+3) begin (a_+b_) => (a, b)