Skip to content
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

BoundsError in 2d comprehension #20078

Closed
andreasnoack opened this issue Jan 16, 2017 · 8 comments
Closed

BoundsError in 2d comprehension #20078

andreasnoack opened this issue Jan 16, 2017 · 8 comments
Labels
kind:bug Indicates an unexpected problem or unintended behavior kind:regression Regression in behavior compared to a previous version

Comments

@andreasnoack
Copy link
Member

From MAT.jl's test suite

julia> Any[v for _ in 1:1, v in (1.0, 2.01, "string", Any["string1" "string2"])]
ERROR: BoundsError: attempt to access 1×4 Array{Any,2} at index [5]
Stacktrace:
 [1] copy!(::Array{Any,2}, ::Base.Generator{Base.Iterators.Prod2{UnitRange{Int64},Tuple{Float64,Float64,String,Array{Any,2}}},##1#2}) at ./abstractarray.jl:499
 [2] _collect(::Type{Any}, ::Base.Generator{Base.Iterators.Prod2{UnitRange{Int64},Tuple{Float64,Float64,String,Array{Any,2}}},##1#2}, ::Base.HasShape) at ./array.jl:313
 [3] collect(::Type{Any}, ::Base.Generator{Base.Iterators.Prod2{UnitRange{Int64},Tuple{Float64,Float64,String,Array{Any,2}}},##1#2}) at ./array.jl:310

Bisection blames #18457

cc: @JeffBezanson

@tkelman tkelman added the kind:bug Indicates an unexpected problem or unintended behavior label Jan 16, 2017
@andreasnoack andreasnoack added the kind:regression Regression in behavior compared to a previous version label Jan 17, 2017
@yuyichao
Copy link
Contributor

This seems to be caused by Base.product with a heterogeneous tuple input. It causes a infinite loop in

for x in Base.product(1:1, (1, "2"))
end

@yuyichao
Copy link
Contributor

It's also important that the first iterator has a single element so probably a wrong handling of edge case there?

@yuyichao
Copy link
Contributor

I think the issue is likely

julia> oftype(Nullable{Int}(), nothing)
Nullable{Int64}()

julia> oftype(Nullable{Any}(), nothing)
Nullable{Any}(nothing)

I assume using typeof(nv2)() should work?

@tkelman
Copy link
Contributor

tkelman commented Feb 12, 2017

that nothing conversion method seems more dangerous than useful in terms of hitting corner cases like this. can we deprecate it?

@nalimilan
Copy link
Member

I wouldn't deprecate it now if we expect Nullable to be replaced with Union{T, Void} soon. I think we just need a new method for convert(Nullable{Any}, ...).

@JeffBezanson
Copy link
Sponsor Member

That workaround is safe, but there's a more general specificity problem. Type{Nullable{T}}, Void used to be more specific than Type{Nullable{T}}, T, and isn't anymore. That should be fixable.

@yuyichao
Copy link
Contributor

Is Type{Nullable{T}}, Void actually more specific though? It matches Type{Nullable{Int}}, Void where as the second one doesn't.

@JeffBezanson
Copy link
Sponsor Member

True, but I think for any arguments where both definitions match, the one that explicitly names Void is arguably more specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior kind:regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

5 participants