Closed
Description
Looking at the segfault in https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_date/2025-03/18/SumOfSquares.primary.log, inference is coming to the wrong answer on master
julia> using MathOptInterface, MutableArithmetics, MultivariateMoments
julia> code_typed(MutableArithmetics.promote_operation, Tuple{typeof(MultivariateMoments.:+), Type{MathOptInterface.VariableIndex}, Type{MathOptInterface.ScalarAffineFunction{Complex{Float64}}} where _A}, optimize=false)
[ Warning: + is defined in Base and is not public in MultivariateMoments
1-element Vector{Any}:
CodeInfo(
@ /home/vtjnash/.julia/packages/MathOptInterface/jGuEH/src/Utilities/mutable_arithmetics.jl:90 within `unknown scope`
1 ─ %1 = MathOptInterface.Utilities.promote_operation::Core.Const(MathOptInterface.Utilities.promote_operation)
│ %2 = $(Expr(:static_parameter, 1))::Core.Const(ComplexF64)
│ %3 = dynamic (%1)(op, %2, F, G)::Core.Const(MathOptInterface.ScalarAffineFunction{ComplexF64})
└── return %3
) => Type{MathOptInterface.ScalarAffineFunction{ComplexF64}}
julia> code_typed(MutableArithmetics.promote_operation, Tuple{typeof(MultivariateMoments.:+), Type{MathOptInterface.VariableIndex}, Type{MathOptInterface.ScalarAffineFunction{Complex{_A}}} where _A}, optimize=false)
1-element Vector{Any}:
CodeInfo(
@ /home/vtjnash/.julia/packages/MathOptInterface/jGuEH/src/Utilities/mutable_arithmetics.jl:90 within `unknown scope`
1 ─ %1 = MathOptInterface.Utilities.promote_operation::Core.Const(MathOptInterface.Utilities.promote_operation)
│ %2 = $(Expr(:static_parameter, 1))::Type{T} where T<:(Complex{_A} where _A)
│ dynamic (%1)(op, %2, F, G)::Union{}
└── Core.Const(:(return %3))::Union{}
) => Union{}
on v1.12 this was
julia> code_typed(MutableArithmetics.promote_operation, Tuple{typeof(MultivariateMoments.:+), Type{MathOptInterface.VariableIndex}, Type{MathOptInterface.ScalarAffineFunction{Complex{_A}}} where _A}, optimize=false)
1-element Vector{Any}:
CodeInfo(
@ /home/vtjnash/.julia/packages/MathOptInterface/jGuEH/src/Utilities/mutable_arithmetics.jl:90 within `unknown scope`
1 ─ %1 = MathOptInterface.Utilities.promote_operation::Core.Const(MathOptInterface.Utilities.promote_operation)
│ %2 = $(Expr(:static_parameter, 1))::Type{T} where T<:(Complex{_A} where _A)
│ %3 = dynamic (%1)(op, %2, F, G)::Type{MathOptInterface.ScalarAffineFunction{Complex{_A}}} where _A
└── return %3
) => Type{MathOptInterface.ScalarAffineFunction{Complex{_A}}} where _A