From 78fee6095da3a52bd6784bd98d318dffc2708f7a Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Fri, 26 Aug 2022 12:16:13 +0200 Subject: [PATCH 1/5] fix invalidations in sort! from Static.jl --- base/sort.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sort.jl b/base/sort.jl index 8a3d2e2871cfe..e69ed8cfa61a0 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -519,7 +519,7 @@ function sort!(v::AbstractVector, lo::Integer, hi::Integer, ::InsertionSortAlg, x = v[i] while j > lo y = v[j-1] - if !lt(o, x, y) + if !(lt(o, x, y)::Bool) break end v[j] = y From 0de5fe58b1e4450ea44619c6542f93eeb12c3fb0 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Fri, 26 Aug 2022 17:04:40 +0200 Subject: [PATCH 2/5] move Bool annotation to definition of lt --- base/sort.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/sort.jl b/base/sort.jl index e69ed8cfa61a0..548eb3b6c7ac0 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -519,7 +519,7 @@ function sort!(v::AbstractVector, lo::Integer, hi::Integer, ::InsertionSortAlg, x = v[i] while j > lo y = v[j-1] - if !(lt(o, x, y)::Bool) + if !lt(o, x, y) break end v[j] = y @@ -1486,8 +1486,8 @@ right(::DirectOrdering) = Right() left(o::Perm) = Perm(left(o.order), o.data) right(o::Perm) = Perm(right(o.order), o.data) -lt(::Left, x::T, y::T) where {T<:Floats} = slt_int(y, x) -lt(::Right, x::T, y::T) where {T<:Floats} = slt_int(x, y) +lt(::Left, x::T, y::T)::Bool where {T<:Floats} = slt_int(y, x) +lt(::Right, x::T, y::T)::Bool where {T<:Floats} = slt_int(x, y) uint_map(x::Float16, ::Left) = ~reinterpret(UInt16, x) uint_unmap(::Type{Float16}, u::UInt16, ::Left) = reinterpret(Float16, ~u) From 6b218f8a8b813ed77551ae64f13b15f4b4a8db75 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 29 Aug 2022 08:32:17 +0200 Subject: [PATCH 3/5] return type assertion with where needs long form --- base/sort.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/base/sort.jl b/base/sort.jl index 548eb3b6c7ac0..acb493496ae3e 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -1486,8 +1486,12 @@ right(::DirectOrdering) = Right() left(o::Perm) = Perm(left(o.order), o.data) right(o::Perm) = Perm(right(o.order), o.data) -lt(::Left, x::T, y::T)::Bool where {T<:Floats} = slt_int(y, x) -lt(::Right, x::T, y::T)::Bool where {T<:Floats} = slt_int(x, y) +function lt(::Left, x::T, y::T)::Bool where {T<:Floats} + slt_int(y, x) +end +function lt(::Right, x::T, y::T)::Bool where {T<:Floats} + slt_int(x, y) +end uint_map(x::Float16, ::Left) = ~reinterpret(UInt16, x) uint_unmap(::Type{Float16}, u::UInt16, ::Left) = reinterpret(Float16, ~u) From e81d329f62e5841ff64aea12e6e8a6432d25365e Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 29 Aug 2022 15:52:48 +0200 Subject: [PATCH 4/5] Revert "return type assertion with where needs long form" This reverts commit 6b218f8a8b813ed77551ae64f13b15f4b4a8db75. The new form did not fix invalidations in Julia 1.8. --- base/sort.jl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/base/sort.jl b/base/sort.jl index acb493496ae3e..548eb3b6c7ac0 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -1486,12 +1486,8 @@ right(::DirectOrdering) = Right() left(o::Perm) = Perm(left(o.order), o.data) right(o::Perm) = Perm(right(o.order), o.data) -function lt(::Left, x::T, y::T)::Bool where {T<:Floats} - slt_int(y, x) -end -function lt(::Right, x::T, y::T)::Bool where {T<:Floats} - slt_int(x, y) -end +lt(::Left, x::T, y::T)::Bool where {T<:Floats} = slt_int(y, x) +lt(::Right, x::T, y::T)::Bool where {T<:Floats} = slt_int(x, y) uint_map(x::Float16, ::Left) = ~reinterpret(UInt16, x) uint_unmap(::Type{Float16}, u::UInt16, ::Left) = reinterpret(Float16, ~u) From 5597c4b1c7f5bb0ca6895f30d01c67375e7dfdbd Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 29 Aug 2022 15:53:23 +0200 Subject: [PATCH 5/5] Revert "move Bool annotation to definition of lt" This reverts commit 0de5fe58b1e4450ea44619c6542f93eeb12c3fb0. --- base/sort.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/sort.jl b/base/sort.jl index 548eb3b6c7ac0..e69ed8cfa61a0 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -519,7 +519,7 @@ function sort!(v::AbstractVector, lo::Integer, hi::Integer, ::InsertionSortAlg, x = v[i] while j > lo y = v[j-1] - if !lt(o, x, y) + if !(lt(o, x, y)::Bool) break end v[j] = y @@ -1486,8 +1486,8 @@ right(::DirectOrdering) = Right() left(o::Perm) = Perm(left(o.order), o.data) right(o::Perm) = Perm(right(o.order), o.data) -lt(::Left, x::T, y::T)::Bool where {T<:Floats} = slt_int(y, x) -lt(::Right, x::T, y::T)::Bool where {T<:Floats} = slt_int(x, y) +lt(::Left, x::T, y::T) where {T<:Floats} = slt_int(y, x) +lt(::Right, x::T, y::T) where {T<:Floats} = slt_int(x, y) uint_map(x::Float16, ::Left) = ~reinterpret(UInt16, x) uint_unmap(::Type{Float16}, u::UInt16, ::Left) = reinterpret(Float16, ~u)