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

Stack overflow when broadcasting results in StaticInt eltype #1

Open
Tokazama opened this issue Oct 17, 2020 · 0 comments
Open

Stack overflow when broadcasting results in StaticInt eltype #1

Tokazama opened this issue Oct 17, 2020 · 0 comments

Comments

@Tokazama
Copy link
Member

Tokazama commented Oct 17, 2020

Found this...

julia> import ArrayInterface: StaticInt

julia> r = StaticInt(1):4
StaticInt{1}():StaticInt{1}():4

julia> broadcast(-, r, StaticInt(1))
ERROR: StackOverflowError:
Stacktrace:
 [1] UnitRange{StaticInt{0}}(::StaticInt{0}, ::StaticInt{3}) at /Users/zchristensen/.julia/packages/ArrayInterface/NbkVT/src/static.jl:108 (repeats 79984 times)

...and traced the issue back to Base._range assuming that UnitRange should be formed with an element type that is a StaticInt.

The easiest way to fix this would be our own Base._range(::StaticInt, ...), but I'm not sure if that's a good entry point since it's not public API.

Edit:
also found this

julia> (StaticInt(1):10)[1:2:6]
ERROR: MethodError: no method matching StepRange{StaticInt{1},Int64}(::StaticInt{1}, ::Int64, ::StaticInt{5})
Closest candidates are:
  StepRange{StaticInt{1},Int64}(::T, ::S, ::T) where {T, S} at range.jl:204
Stacktrace:
 [1] _rangestyle(::Base.Ordered, ::Base.ArithmeticWraps, ::StaticInt{1}, ::Int64, ::Int64) at ./range.jl:118
 [2] _range at ./range.jl:116 [inlined]
 [3] #range#43 at ./range.jl:91 [inlined]
 [4] getindex(::ArrayInterface.OptionallyStaticUnitRange{StaticInt{1},Int64}, ::StepRange{Int64,Int64}) at ./range.jl:713
 [5] top-level scope at REPL[26]:1
@ChrisRackauckas ChrisRackauckas transferred this issue from JuliaArrays/ArrayInterface.jl Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant