fix similar() ambiguity with Base#233
Conversation
|
Wow, that's pretty bad... Definitely surprising that something like this was not caught by tests. I agree we should yank the release (JuliaRegistries/General#62675) so that we can figure this out without having to rush. I confess I am confused because OffsetArrays itself does not follow the guideline suggested by the Base comment (see here), but I suppose they can get away with it as they don't specialize on array type. CC: @timholy (to double check that the approach in this PR is 100% correct) Fixes: #234 |
|
My original commit in this PR definitely doesn't eliminate all ambiguitites. I ran Aqua.jl ambiguity detection, and it found a couple more (mostly in reshape) that are realizable. I wanted to add Aqua tests to the testsuite, but didn't: it has false-positives and reports ambiguities that cannot be realized due to the existince of more specific methods. Also, the AbstractUnitRange is actually needed: See the 2nd commit that fixes these issues. |
|
I've left a few minor comments, but this seems good. It is slightly worrying to me that the signatures become so complex, but I don't really see a way around it. |
Yes, unfortunately, there is no clean way for structarrays to say "whatever the axes are, |
map(f, StructArray)stopped working in 0.6.9 due to a method ambiguity:This PR fixes the ambiguity, and adds corresponding tests.
I'm not really familiar with the
similar()machinery, but the signature in this PR follow the Base recommendation at https://github.com/JuliaLang/julia/blob/master/base/abstractarray.jl#L810-L814. Specifically, there should beUnion{Integer, UnitRange}(this PR) instead ofUnion{Integer, AbstractUnitRange}(0.6.9).