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

iszero(::SVector{0}) broken #778

Closed
pablosanjose opened this issue May 1, 2020 · 5 comments · Fixed by #780
Closed

iszero(::SVector{0}) broken #778

pablosanjose opened this issue May 1, 2020 · 5 comments · Fixed by #780
Labels

Comments

@pablosanjose
Copy link
Contributor

pablosanjose commented May 1, 2020

Something in v0.12.2 introduced a severe breaking change: it has made iszero(SVector{0,Int}()) a BoundsError, whereas before (in v0.12.1) it was true. In my opinion the old behavior made more sense, as indeed zero(SVector{0,Int}) === SVector{0,Int}()

@pablosanjose pablosanjose changed the title iszero(::SVector{0}) broken by #263 iszero(::SVector{0}) broken May 1, 2020
@c42f c42f added the bug label May 2, 2020
@c42f
Copy link
Member

c42f commented May 2, 2020

Unexpected bugs tend to be breaking changes! Thanks for the report :-)

@tkf what do you think? Likely this is related to some refactoring done in #750 which now causes

julia> reduce((x,y)->true, SVector{0,Int}(), init=true)
ERROR: BoundsError: attempt to access ()
  at index [1]
Stacktrace:
 [1] getindex(::Tuple, ::Int64) at ./tuple.jl:24
 [2] getindex(::SArray{Tuple{0},Int64,1,0}, ::Int64) at /home/chris/.julia/dev/StaticArrays/src/SVector.jl:37
 [3] macro expansion at /home/chris/.julia/dev/StaticArrays/src/mapreduce.jl:129 [inlined]
 [4] _mapfoldl(::typeof(identity), ::var"#9#10", ::Colon, ::Bool, ::Size{(0,)}, ::SArray{Tuple{0},Int64,1,0}) at /home/chris/.julia/dev/StaticArrays/src/mapreduce.jl:116
 [5] _mapreduce(::Function, ::Function, ::Function, ::Bool, ::Size{(0,)}, ::SArray{Tuple{0},Int64,1,0}) at /home/chris/.julia/dev/StaticArrays/src/mapreduce.jl:113
 [6] _reduce(::Function, ::SArray{Tuple{0},Int64,1,0}, ::Function, ::Bool) at /home/chris/.julia/dev/StaticArrays/src/mapreduce.jl:198
 [7] reduce(::Function, ::SArray{Tuple{0},Int64,1,0}; dims::Function, init::Bool) at /home/chris/.julia/dev/StaticArrays/src/mapreduce.jl:184
 [8] top-level scope at REPL[2]:1

@tkf
Copy link
Member

tkf commented May 2, 2020

Oops, yes, there is a bug in empty array handling. #780 should fix this.

@tkf tkf closed this as completed in #780 May 3, 2020
@c42f
Copy link
Member

c42f commented May 3, 2020

I'll do a quickfix release 0.12.3 containing this.

@c42f
Copy link
Member

c42f commented May 3, 2020

JuliaRegistries/General#14076

@pablosanjose
Copy link
Contributor Author

That was quick! Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants