The following code throws an error:
using JuMP
m = Model()
@variable(m, x)
y = Vector{Any}(undef, 2)
y[1] = @variable(m, base_name=“y1”)
y[2] = 1.0
@constraint(m, sum([x * yi for yi in y]) == 1.0)
ERROR: MethodError: no method matching zero(::Type{AbstractJuMPScalar})
Closest candidates are:
zero(::Union{Type{P}, P}) where P<:Dates.Period at C:\Users\garys.julia\juliaup\julia-1.8.5+0.x64.w64.mingw32\share\julia\stdlib\v1.8\Dates\src\periods.jl:53
zero(::T) where T<:Dates.TimeType at C:\Users\garys.julia\juliaup\julia-1.8.5+0.x64.w64.mingw32\share\julia\stdlib\v1.8\Dates\src\types.jl:450
zero(::LinearAlgebra.Diagonal{T, StaticArraysCore.SVector{N, T}}) where {N, T} at C:\Users\garys.julia\packages\StaticArrays\VLqRb\src\SDiagonal.jl:41
…
Replacing y[2] = 1.0
with y[2] = one(AffExpr)
produces no errors, as does rewriting the constraint as
@constraint(m, sum(+, [x * yi for yi in y]) == 1.0)
Is this a bug?