julia icon indicating copy to clipboard operation
julia copied to clipboard

Assume :nothrow in iterating over tuples

Open jishnub opened this issue 1 year ago • 1 comments

On master,

julia> Base.infer_effects(iterate, (Tuple{Int,Int,Int}, Int))
(+c,+e,!n,+t,+s,+m,+u)

Since the indexing is only carried out for valid indices, it should be safe to mark this as nothrow. After this PR,

julia> Base.infer_effects(iterate, (Tuple{Int,Int,Int}, Int))
(+c,+e,+n,+t,+s,+m,+u)

jishnub avatar May 02 '24 10:05 jishnub

Is is also valid to annotate iterate for Array with this?

KristofferC avatar May 02 '24 10:05 KristofferC

Not Array in general, as there may be uninitialized values that will cause it to throw. But maybe if the element type isbits?

jakobnissen avatar May 02 '24 14:05 jakobnissen