Skip to content

Commit bf2a197

Browse files
authored
Define zero(::StaticInt)
The motivation is that we have this on Julia nightly: ```julia julia> zero(static(9)) ERROR: TypeError: in typeassert, expected StaticInt{9}, got a value of type StaticInt{0} Stacktrace: [1] convert @ ./number.jl:7 [inlined] [2] oftype(x::StaticInt{9}, y::Int64) @ Base ./essentials.jl:469 [3] zero(x::StaticInt{9}) @ Base ./number.jl:308 [4] top-level scope @ REPL[11]:1 ``` The type assert was added (versus Julia 1.8) because of invalidations.
1 parent 917bbac commit bf2a197

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Static.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ end
4343

4444
Base.getindex(x::Tuple, ::StaticInt{N}) where {N} = getfield(x, N)
4545

46+
Base.zero(@nospecialize(::StaticInt)) = StaticInt{0}()
47+
4648
Base.to_index(x::StaticInt) = known(x)
4749
function Base.checkindex(::Type{Bool}, inds::AbstractUnitRange, ::StaticNumber{N}) where {N}
4850
checkindex(Bool, inds, N)

0 commit comments

Comments
 (0)