-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sorting an array of Union{} fails on nightly #45280
Comments
Does this matter? Why would you use an array that you can't put an element in? |
It matters to me: it broke my package: https://github.com/simonbyrne/KeywordDispatch.jl/runs/6391666554?check_suite_focus=true One case is if you sort a collected tuple: the edge case, collecting an empty tuple returns such an array:
|
A fix? diff --git a/base/sort.jl b/base/sort.jl
index 23579abd77..e4e80d49fe 100644
--- a/base/sort.jl
+++ b/base/sort.jl
@@ -732,7 +732,7 @@ end
# For AbstractVector{Bool}, counting sort is always best.
# This is an implementation of counting sort specialized for Bools.
-function sort!(v::AbstractVector{<:Bool}, lo::Integer, hi::Integer, a::AdaptiveSort, o::Ordering)
+function sort!(v::AbstractVector{Bool}, lo::Integer, hi::Integer, a::AdaptiveSort, o::Ordering)
first = lt(o, false, true) ? false : lt(o, true, false) ? true : return v
count = 0
@inbounds for i in lo:hi |
But then we will notice that the UIntMappable function is implemented wrong/broken/buggy too (added in #44230 recently). Fixing that bug seems to make this case work: diff --git a/base/sort.jl b/base/sort.jl
index 23579abd77..750f696bd4 100644
--- a/base/sort.jl
+++ b/base/sort.jl
@@ -1350,7 +1350,7 @@ uint_unmap(::Type{T}, u::Unsigned, ::ForwardOrdering) where T <: Signed =
# unsigned(Int) is not available during bootstrapping.
for (U, S) in [(UInt8, Int8), (UInt16, Int16), (UInt32, Int32), (UInt64, Int64), (UInt128, Int128)]
- @eval UIntMappable(::Type{<:Union{$U, $S}}, ::ForwardOrdering) = $U
+ @eval UIntMappable(::Union{Type{$U}, Type{$S}}, ::ForwardOrdering) = $U
end
# Floats are not UIntMappable under regular orderings because they fail on NaN edge cases. |
The text was updated successfully, but these errors were encountered: