-
-
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
(::Type)(args...) constructors with Union args mess up method sorting #30794
Comments
|
No need to apologize :) We can expect bugs like this to appear and disappear as we mess with specificity, since it is still not a well-behaved relation. |
Parsers.jl, used by CSV.jl, seems to define several methods of this variety which are causing problems in other packages. As an example, some incorrect output:
The output should actually be:
I can work around the issue for several of the methods in Parsers.jl but there was a method or two that was not functionally equivalent after my fix. This issue in particular is actually worse than it looks because the incorrect method being called here leads to a stack overflow which sometimes is not caught, resulting in Julia crashing... My version info:
|
works now: julia> methods(Demo.OffsetArray)
# 3 methods for type constructor:
[1] (::Type{Main.Demo.OffsetArray})(A::AbstractArray{T,0}) where T in Main.Demo at REPL[2]:14
[2] (::Type{Main.Demo.OffsetArray})(A::AbstractArray{T,N}, offsets::Vararg{Int64,N}) where {T, N} in Main.Demo at REPL[2]:8
[3] (::Type{Main.Demo.OffsetArray})(A::AbstractArray{T,N}, axs::Vararg{AbstractUnitRange,N}) where {T, N} in Main.Demo at REPL[2]:16 I'm updating the method sorter logic soon, and will add a test then that'll cover this case. |
Defining a method
(::Type)(x::U, ...)
whereU
is aUnion
seems to mess up method sorting, in a manner that's dependent upon precompilation:Session:
Note that the
::AbstractArray{T,0}
method is of too-low specificity. There are lots of things you can do to fix this:ArrayInitializer
method in the source fileArrayInitializer
to a concrete type, e.g.,Missing
.This appears to be the root cause of timholy/Revise.jl#234.
The text was updated successfully, but these errors were encountered: