File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,15 @@ Remove the line nodes from a block or array of expressions.
52
52
Compare `quote end` vs `rmlines(quote end)`
53
53
"""
54
54
rmlines (x) = x
55
- rmlines (x:: Expr ) = Expr (x. head, filter (x-> ! isline (x), x. args)... )
55
+ function rmlines (x:: Expr )
56
+ # Do not strip the first argument to a macrocall, which is
57
+ # required.
58
+ if x. head == :macrocall && length (x. args) >= 2
59
+ Expr (x. head, x. args[1 : 2 ]. .. , filter (x-> ! isline (x), x. args[3 : end ])... )
60
+ else
61
+ Expr (x. head, filter (x-> ! isline (x), x. args)... )
62
+ end
63
+ end
56
64
57
65
striplines (ex) = prewalk (rmlines, ex)
58
66
Original file line number Diff line number Diff line change @@ -96,6 +96,15 @@ macro splitcombine(fundef) # should be a no-op
96
96
esc (MacroTools. combinedef (dict))
97
97
end
98
98
99
+ # Macros for testing that splitcombine doesn't break
100
+ # macrocalls in bodies
101
+ macro zeroarg ()
102
+ :(1 )
103
+ end
104
+ macro onearg (x)
105
+ :(1 + $ (esc (x)))
106
+ end
107
+
99
108
let
100
109
# Ideally we'd compare the result against :(function f(x)::Int 10 end),
101
110
# but it fails because of :line and :block differences
120
129
@test fwhere (10 ) == Int
121
130
@splitcombine manywhere (x:: T , y:: Vector{U} ) where T <: U where U = (T, U)
122
131
@test manywhere (1 , Number[2.0 ]) == (Int, Number)
132
+ @splitcombine fmacro0 () = @zeroarg
133
+ @test fmacro0 () == 1
134
+ @splitcombine fmacro1 () = @onearg 1
135
+ @test fmacro1 () == 2
123
136
124
137
struct Foo{A, B}
125
138
a:: A
You can’t perform that action at this time.
0 commit comments