-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix various JET errors #2269
Fix various JET errors #2269
Conversation
src/Utilities/objective_container.jl
Outdated
function MOI.get( | ||
o::ObjectiveContainer{T}, | ||
::MOI.ObjectiveFunction{F}, | ||
) where {T,F} | ||
if o.scalar_affine !== nothing | ||
return convert(F, o.scalar_affine) | ||
return convert(F, _get_scalar_affine(o)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the changes in this file deal with the problem that o.scalar_affine::Union{Nothing,MOI.ScalarAffineFunction{T}}
.
At runtime, the if
statement handles the nothing
case, so we never call convert(F, nothing)
, but it's useful to have a type-stable way to get the non-nothing function.
Although writing this now, I wonder if I could use _not_nothing(o.scalar_affine)
to disambiguate the union.
intvar_idx = Int[] | ||
c = nothing | ||
funcs = nothing | ||
funcs = MOI.VectorAffineFunction{T}[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just a type stability issue, where various variables were initialized as nothing
and then swapped to vectors.
_assert_has_model(model.model, attr) | ||
return MOI.get(model.model, attr) | ||
inner = _assert_has_model(model.model, attr) | ||
return MOI.get(inner, attr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously compiler couldn't prove that model.model
was not nothing
because the check happened in _assert_has_model
. Okay at runtime, not at compilation.
@@ -1319,7 +1319,7 @@ function parse_name_line(data::TempMPSModel, line::String) | |||
if m === nothing | |||
error("Malformed NAME line: ", line) | |||
end | |||
data.name = strip(m[1]) | |||
data.name = strip(m[1]::AbstractString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's actually a bunch of problems where we assume that the regex finds something.
Part of #2268
Brings count from 211 down to 196. I'll comment in-line.