diff --git a/src/user.jl b/src/user.jl index b183283e..93878649 100644 --- a/src/user.jl +++ b/src/user.jl @@ -482,7 +482,7 @@ function replace_value(ex::Expr) ex.args[i]=replace_value(ex.args[i]) end end - return Core.eval(@__MODULE__, ex) + return ex elseif ex.head == :tuple for i=1:length(ex.args) if typeof(ex.args[i])==Symbol @@ -491,7 +491,7 @@ function replace_value(ex::Expr) error("only use symbols inside the tuple.") end end - return Core.eval(@__MODULE__, ex) + return ex else error("Expr head $(ex.head) must equal :call or :tuple") end @@ -505,7 +505,7 @@ function replace_value(sym::Symbol) m = unitmodules[inds[end]] u = getfield(m, sym) - + any(u != u1 for u1 in getfield.(unitmodules[inds[1:(end-1)]], sym)) && @warn(string("Symbol $sym was found in multiple registered unit modules. ", "We will use the one from $m.")) diff --git a/test/runtests.jl b/test/runtests.jl index 28e25f22..89dcc0bf 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -292,14 +292,14 @@ end end @testset "Unit string macro" begin - @test macroexpand(@__MODULE__, :(u"m")) == m - @test macroexpand(@__MODULE__, :(u"m,s")) == (m,s) - @test macroexpand(@__MODULE__, :(u"1.0")) == 1.0 - @test macroexpand(@__MODULE__, :(u"m/s")) == m/s - @test macroexpand(@__MODULE__, :(u"1.0m/s")) == 1.0m/s - @test macroexpand(@__MODULE__, :(u"m^-1")) == m^-1 - @test macroexpand(@__MODULE__, :(u"dB/Hz")) == dB/Hz - @test macroexpand(@__MODULE__, :(u"3.0dB/Hz")) == 3.0dB/Hz + @test u"m" == m + @test u"m,s" == (m,s) + @test u"1.0" == 1.0 + @test u"m/s" == m/s + @test u"1.0m/s" == 1.0m/s + @test u"m^-1" == m^-1 + @test u"dB/Hz" == dB/Hz + @test u"3.0dB/Hz" == 3.0dB/Hz @test_throws LoadError macroexpand(@__MODULE__, :(u"N m")) @test_throws LoadError macroexpand(@__MODULE__, :(u"abs(2)")) @test_throws LoadError @eval u"basefactor"