-
-
Notifications
You must be signed in to change notification settings - Fork 398
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 promotion rules for GenericNonlinearExpr #3483
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3483 +/- ##
==========================================
- Coverage 98.09% 98.04% -0.06%
==========================================
Files 37 37
Lines 5518 5525 +7
==========================================
+ Hits 5413 5417 +4
- Misses 105 108 +3
☔ View full report in Codecov by Sentry. |
This fixes the UnitJuMP test failure, although UnitJuMP still commits type piracy. |
It's still possible to generate julia> using JuMP
julia> model = Model();
julia> @variable(model, x);
julia> y = [i == 1 ? x : sin(x) for i in 1:2]
2-element Vector{AbstractJuMPScalar}:
x
sin(x)
julia> @objective(model, Min, [i == 1 ? x : sin(x) for i in 1:2])
ERROR: MethodError: no method matching moi_function(::Vector{AbstractJuMPScalar})
Closest candidates are:
moi_function(::AbstractConstraint) at /Users/oscar/.julia/dev/JuMP/src/constraints.jl:550
moi_function(::AbstractVariableRef) at /Users/oscar/.julia/dev/JuMP/src/variables.jl:575
moi_function(::Vector{var"#s65"} where var"#s65"<:AbstractVariableRef) at /Users/oscar/.julia/dev/JuMP/src/variables.jl:584
...
Stacktrace:
[1] set_objective_function(model::Model, func::Vector{AbstractJuMPScalar})
@ JuMP ~/.julia/dev/JuMP/src/objective.jl:146
[2] set_objective(model::Model, sense::MathOptInterface.OptimizationSense, func::Vector{AbstractJuMPScalar})
@ JuMP ~/.julia/dev/JuMP/src/objective.jl:175
[3] macro expansion
@ ~/.julia/dev/JuMP/src/macros.jl:1850 [inlined]
[4] top-level scope
@ REPL[5]:1
julia> @objective(model, Min, y)
ERROR: MethodError: no method matching moi_function(::Vector{AbstractJuMPScalar}) So perhaps we need a better error for the fallback. |
Thoughts @pulsipher? |
@trulsf fixed UnitJuMP, but I think this is the right thing regardless. We can always add back support for |
Closes #3482
https://github.com/jump-dev/JuMP.jl/actions/runs/6067289679