ModiaSim / Modia.jl

Modeling and simulation of multidomain engineering systems
MIT License
321 stars 38 forks source link

Fixing @U_str code to reflect changes in Unitful.jl. #78

Closed crlaugh closed 5 years ago

tshort commented 5 years ago

Wouldn't it be better to switch back to using u"" instead, or is U"" needed for some reason?

MartinOtter commented 5 years ago

Wouldn't it be better to switch back to using u"" instead, or is U"" needed for some reason?

Yes: Our workaround with Unitful_U_Str.jl should be removed. I will try this now

MartinOtter commented 5 years ago

I have removed the Unitful_U_Str.jl workaround (in my local repository), but get the same error as Chris with his changes:

include("$(Modia.ModiaDir)/test/models/TestVariableTypes.jl")
ERROR: LoadError: LoadError: Symbol `V` was found in unit module Unitful, but was not loaded into Main.anonymous. Consider `using Unitful` within `Main.anonymous`?
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] replace_value(::Module, ::Symbol) at D:\otter\home\.julia\packages\Unitful\A3sNy\src\user.jl:540
 [3] @u_str(::LineNumberNode, ::Module, ::Any) at D:\otter\home\.julia\packages\Unitful\A3sNy\src\user.jl:495
 [4] eval at .\boot.jl:319 [inlined]
 [5] evaluate at D:\otter\home\.julia\dev\Modia\src\language\Execution.jl:24 [inlined]
 [6] #prepare_ida#5(::Bool, ::Bool, ::Function, ::Modia.Instantiation.Instance, ::Array{Symbol,1}, ::Dict{Symbol,Any}) at D:\otter\home\.julia\dev\Modia\src\language\Execution.jl:530

Modia\src\language\Execution.jl:530 is the workaround that was introduced to get rid off a crash of Julia 1.0:

const MODULES = Module[]
evaluate(m, x) = Core.eval(m, x)
...
push!(MODULES, Module())   <=== Line 530
index_Module_F = length(MODULES)
F = evaluate(MODULES[index_Module_F], F_code)

I do not know what needs to be done.

MartinOtter commented 5 years ago

Closing this pull request because issue has been solved with pull request #80 (= the previous workaround for Unitful was removed and units are now again be defined with u"..." and no longer with U"...".