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

Assume :nothrow in iterating over tuples #54330

Merged
merged 2 commits into from
May 2, 2024
Merged

Assume :nothrow in iterating over tuples #54330

merged 2 commits into from
May 2, 2024

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented May 2, 2024

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 jishnub requested a review from aviatesk May 2, 2024 10:01
test/tuple.jl Outdated Show resolved Hide resolved
@KristofferC
Copy link
Member

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

Co-authored-by: Shuhei Kadowaki <[email protected]>
@jakobnissen
Copy link
Contributor

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

@Keno Keno merged commit f712512 into master May 2, 2024
7 checks passed
@Keno Keno deleted the jishnub/tupleiterate branch May 2, 2024 16:41
lazarusA pushed a commit to lazarusA/julia that referenced this pull request Jul 12, 2024
On master,
```julia
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
julia> Base.infer_effects(iterate, (Tuple{Int,Int,Int}, Int))
(+c,+e,+n,+t,+s,+m,+u)
```

---------

Co-authored-by: Shuhei Kadowaki <[email protected]>
@nsajko nsajko added the iteration Involves iteration or the iteration protocol label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iteration Involves iteration or the iteration protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants