-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
RelationalAI/julia
#227Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorfixed on masterregression 1.10Regression in the 1.10 releaseRegression in the 1.10 releasetypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch
Description
The following code
struct NullableVector{T,V<:AbstractVector{T}} <: AbstractVector{Union{Nothing,T}}
data::V
end
const NullableColumn{T} = NullableVector{T,Vector{T}}
const Column{T} = Union{Vector{T},NullableColumn{T}}
_maybe_push!(::Vector{T}) where {T} = sizeof(T)
_maybe_push!(column::NullableVector{T}) where {T} = _maybe_push!(column.data)
_maybe_push!(column::Column) = (println("Why we dispatch here? Input type is Vector type `$(typeof(column))`"); 0)
function _recycle!(columns::Vector{Column})
for col in columns
_maybe_push!(col)
end
end
# Repro
cols = Column[Int[], UInt[], Float64[]]
_recycle!(cols)Prints the following on Julia 1.10.9:
Why we dispatch here? Input type is Vector type `Vector{Int64}`
Why we dispatch here? Input type is Vector type `Vector{UInt64}`
Why we dispatch here? Input type is Vector type `Vector{Float64}`
I.e. we're dispatching to the _maybe_push!(column::Column) method, while the more specific _maybe_push!(::Vector{T}) method exists.
This does not reproduce if we @noinline the _maybe_push!(col) call site.
This issue doesn't reproduce on Julia 1.11.4 and 1.13.0-DEV.241, the expected method is selected.
nickrobinson251
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorfixed on masterregression 1.10Regression in the 1.10 releaseRegression in the 1.10 releasetypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch