Closed Roger-luo closed 5 years ago
Oh, thanks, the scoping seems to be broken while expanding nested macros, e.g.,
module DefinitionModule
export @addyz
macro addy(x)
esc(:($x + y))
end
macro addyz(x)
esc(:(@addy($x) + z))
end
function test(y, z)
@addyz 1
end
@assert test(2, 3) == 6
end
using .DefinitionModule
function test(y, z)
@addyz 1
end
test(2, 3) # ERROR: LoadError: UndefVarError: @addy not defined
I directly used @match
in the generated code of @λ
, which made @match
necessary for the callee of any macro that invoke @λ
. That's too bad for @λ
is not totally unusable!
However, in the following days(about one week) I have no time to fix this extremely important issue. Could you please help me with this? I think it won't cost much time, just avoid macrocalls inside quote expressions and, export corresponding function implementations gen_lambda
, gen_match
, gen_when
for macros @λ
, @match
, @when
, respectively.
It seems that it's resolved now?
Yeah, fixed.
MWE: copying what's in here: https://github.com/thautwarm/MLStyle-Playground/blob/master/StaticCapturing.jl
to a module. The scoping is not correct.