You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did a lot of testing and trying under the ENV of Julia v1.10 and the latest v1.11.1, vscode 1.94.2
and the latest 1.95.3, vscode julia extension v1.124.2 and the latest 1.127.2:
Only the following package combination (old version) can run my code, and DynamicQuantities v0.13.2 can work. If upgrade any of these packages, an error will occur. I guess this may not be a bug of vscode.
The error is following when Run Without Debugging. the paragraph of MethodError(DynamicQuantities.uconvert ......before "ERROR: LoadError..." was the output when I added a line of println(e) at function parse_variable_arg in model_parsing.jl:
MethodError(DynamicQuantities.uconvert, (1.0 m² s⁻³ A⁻² kg, 1.0), 0x00000000000069c5)
ERROR: LoadError: MethodError: no method matching setmetadata(::Nothing, ::Type{ModelingToolkit.VariableUnit}, ::DynamicQuantities.Quantity{Float64, DynamicQuantities.Dimensions{DynamicQuantities.FixedRational{Int32, 25200}}})
The function`setmetadata` exists, but no method is defined for this combination of argument types.
Closest candidates are:setmetadata(::Num, ::Any, ::Any)
@ Symbolics C:\Users\TCY\.julia\packages\Symbolics\YbNrd\src\Symbolics.jl:187setmetadata(::Complex{Num}, ::Any, ::Any)
@ Symbolics C:\Users\TCY\.julia\packages\Symbolics\YbNrd\src\Symbolics.jl:187setmetadata(::SymbolicUtils.Symbolic, ::DataType, ::Any)
@ SymbolicUtils C:\Users\TCY\.julia\packages\SymbolicUtils\jf8aQ\src\types.jl:685
ERROR: LoadError: No or invalid units provided for'R'
Stacktrace:
[1] set_scalar_metadata(x::Nothing, V::Type, val::DynamicQuantities.Quantity{Float64, DynamicQuantities.Dimensions{DynamicQuantities.FixedRational{Int32, 25200}}})
@ Symbolics C:\Users\TCY\.julia\packages\Symbolics\YbNrd\src\variable.jl:43
[2] #__Resistor__#11
@ C:\Users\TCY\.julia\packages\UnPack\EkESO\src\UnPack.jl:905 [inlined]
[3] __Resistor__(; name::Symbol, useHeatPort::Bool, conditionalHeatPort__useHeatPort::Nothing, R::Float64, T_ref::ModelingToolkit.NoValue, alpha::ModelingToolkit.NoValue, R_actual::ModelingToolkit.NoValue)
@ Systemize.Electrical .\none:0
[4] __Resistor__
@ .\none:0 [inlined]
[5] #_#441
@ C:\Users\TCY\.julia\packages\ModelingToolkit\0O7FS\src\systems\model_parsing.jl:25 [inlined]
[6] macro expansion
@ C:\Users\TCY\.julia\packages\ModelingToolkit\0O7FS\src\systems\abstractsystem.jl:2113 [inlined]
[7] __Rc__(; name::Symbol, useHeatPort::Bool, resistor__R::Nothing, resistor__useHeatPort::Nothing, capacitor__C::Nothing, source__V::Nothing, fixedTemperature__T::Nothing)
@ Systemize.Electrical C:\Users\TCY\.julia\packages\ModelingToolkit\0O7FS\src\systems\model_parsing.jl:138
[8] __Rc__
@ C:\Users\TCY\.julia\packages\ModelingToolkit\0O7FS\src\systems\model_parsing.jl:138 [inlined]
[9] #_#441
@ C:\Users\TCY\.julia\packages\ModelingToolkit\0O7FS\src\systems\model_parsing.jl:25 [inlined]
[10] top-level scope
@ C:\Users\TCY\.julia\packages\ModelingToolkit\0O7FS\src\systems\abstractsystem.jl:2113
[11] include(fname::String)
@ Main .\sysimg.jl:38
[12] run(debug_session::VSCodeDebugger.DebugAdapter.DebugSession, error_handler::VSCodeDebugger.var"#3#4"{String})
@ VSCodeDebugger.DebugAdapter c:\Users\TCY\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\DebugAdapter\src\packagedef.jl:122
[13] startdebugger()
@ VSCodeDebugger c:\Users\TCY\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\VSCodeDebugger\src\VSCodeDebugger.jl:45
[14] top-level scope
@ c:\Users\TCY\.vscode\extensions\julialang.language-julia-1.127.2\scripts\debugger\run_debugger.jl:12
[15] include(mod::Module, _path::String)
@ Base .\Base.jl:557
[16] exec_options(opts::Base.JLOptions)
@ Base .\client.jl:323
[17] _start()
@ Base .\client.jl:531
error("No or invalid units provided for \'" * string(:($$vv)) is at the following function in model_parsing.jl
functionparse_variable_arg(dict, mod, arg, varclass, kwargs, where_types)
vv, def, metadata_with_exprs =parse_variable_def!(
dict, mod, arg, varclass, kwargs, where_types)
if!(vv isa Tuple)
name =getname(vv)
varexpr =ifhaskey(metadata_with_exprs, VariableUnit)
unit = metadata_with_exprs[VariableUnit]
quote$name =if$name ===$NO_VALUE
$setdefault($vv, $def)
elsetry$setdefault($vv, $convert_units($unit, $name))
catch e
ifisa(e, $(DynamicQuantities.DimensionError)) ||isa(e, $(Unitful.DimensionError))
error("Unable to convert units for \'"*string(:($$vv)) *"\'")
elseifisa(e, MethodError)
error("No or invalid units provided for \'"*string(:($$vv)) *"\'")
println(e)
elserethrow(e)
endendendendelse
The Resistor code in my code is as following. My temporary Unit solution like unit = u("Resistance") had been described at the issue . After I learned Julia macro and mtk, I would also like to contribute some code.
The error becomes as following when Start Debugging.
┌ Error: Some Julia code in the VS Code extension crashed
└ @ VSCodeDebugger c:\Users\TCY\.vscode\extensions\julialang.language-julia-1.127.2\scripts\error_handler.jl:15
ERROR: UndefVarError:`uuid4` not defined in`VSCodeDebugger.DebugAdapter`
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name may be made accessible by importing UUIDs in the current active module Main
Stacktrace:
[1] stack_trace_request(debug_session::VSCodeDebugger.DebugAdapter.DebugSession, params::VSCodeDebugger.DebugAdapter.StackTraceArguments)
@ VSCodeDebugger.DebugAdapter c:\Users\TCY\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\DebugAdapter\src\debugger_requests.jl:400
[2] (::VSCodeDebugger.DebugAdapter.var"#110#139"{VSCodeDebugger.DebugAdapter.DebugSession})(params::VSCodeDebugger.DebugAdapter.StackTraceArguments)
@ VSCodeDebugger.DebugAdapter c:\Users\TCY\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\DebugAdapter\src\packagedef.jl:73
[3] dispatch_msg(x::VSCodeDebugger.DebugAdapter.DAPRPC.DAPEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::VSCodeDebugger.DebugAdapter.DAPRPC.MsgDispatcher, msg::Dict{String, Any})
@ VSCodeDebugger.DebugAdapter.DAPRPC c:\Users\TCY\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\DebugAdapter\src\DAPRPC\typed.jl:89
[4] (::VSCodeDebugger.DebugAdapter.var"#132#161"{Dict{String, Any}, VSCodeDebugger.var"#3#4"{String}, VSCodeDebugger.DebugAdapter.DAPRPC.MsgDispatcher, VSCodeDebugger.DebugAdapter.DAPRPC.DAPEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}})()
@ VSCodeDebugger.DebugAdapter c:\Users\TCY\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\DebugAdapter\src\packagedef.jl:98
The text was updated successfully, but these errors were encountered:
wang890
changed the title
Error at function parse_variable_arg: LoadError MethodError, No or invalid units provided
function parse_variable_arg: LoadError MethodError, No or invalid units provided
Nov 30, 2024
Describe the bug 🐞
I did a lot of testing and trying under the ENV of
Julia v1.10
and the latestv1.11.1
,vscode 1.94.2
and the latest
1.95.3
,vscode julia extension v1.124.2
and the latest1.127.2
:Only the following package combination (old version) can run my code, and DynamicQuantities v0.13.2 can work. If upgrade any of these packages, an error will occur. I guess this may not be a bug of vscode.
when I used the following package combination (compat version) of ModelingToolkit
project.toml [compat]
, the same error occurredwhen I used all the latest version as follows, the same error occurred
The error is following when Run Without Debugging. the paragraph of
MethodError(DynamicQuantities.uconvert ......
before "ERROR: LoadError..." was the output when I added a line ofprintln(e)
atfunction parse_variable_arg
inmodel_parsing.jl
:error("No or invalid units provided for \'" * string(:($$vv))
is at the following function inmodel_parsing.jl
The Resistor code in my code is as following. My temporary Unit solution like
unit = u("Resistance")
had been described at the issue . After I learned Julia macro and mtk, I would also like to contribute some code.The error becomes as following when Start Debugging.
The text was updated successfully, but these errors were encountered: