Exporting from a nested module

Hello, I have a module called MathSolver with another module called Parser inside it. I define a macro @math inside the Parser module, which I want to be available when someone uses using MathSolver. However, I can’t figure out how to achive this, and I get the following error:

Tests: Error During Test at .../runtests.jl:3
  Got exception outside of a @test
  LoadError: UndefVarError: @math not defined

MathSolver.jl

module MathSolver

include("Parser.jl")

export @math

end

Parser.jl

module Parser

export @math

macro math(expression)
    # ...
end

end

parsertest.jl

using MathSolver

# It can parse a simple expression
plus = new_node("+")
append_child!(plus, "x")
append_child!(plus, 4)

result = @math x + 4
@test result == plus

I hope someone can help me. Thank you!

or add

using .Parser

after the include .

(including the module doesn’t has the same effect of using , it does not bring the module exported things into scope)

2 Likes