@variable
declarations returning empty container should have VariableRef
element type
#3499
Labels
@variable
declarations returning empty container should have VariableRef
element type
#3499
Is your feature request related to a problem? Please describe.
On latest tagged,
@variable(m, x[1:0])
returns aVector{Any}
. Because of this, code which usesx
as an input cannot infer the containers element type. An example of how this can go wrong is if one callssum(x)
it will throw an error because there is nozero(Any)
, where aszero(VariableRef)
gives a zeroAffExpr
.Describe the solution you'd like
The simplest solution would be to check for empty returns and convert them to
Array{VariableRef}
. However, I realize that this ignores the possibility of other variable types, so, alternatively, it might be nice to add a keyword argument. Preferably, this would still default to something other thanAny
.Describe alternatives you've considered
You can
convert
the result, but it seems undesirable to have to do the check.Additional context
I think previous versions of JuMP returned a
VariableRef
container, but I haven't verified this.The text was updated successfully, but these errors were encountered: