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

Add methods to index identityUnitRange/Slice with another IdentityUnitRange #41224

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented Jun 14, 2021

Adding these methods lets OffsetArrays define getindex(::AbstractUnitRange, ::IdentityUnitRange) without ambiguities. This is in the domain of sanctioned type-piracy, as the result is an offset range in general and cannot be represented correctly using Base types.

Re: JuliaArrays/OffsetArrays.jl#244

cc: @johnnychen94

Edit: this also fixes an indexing bug in IdentityUntiRange:
master

julia> r = Base.IdentityUnitRange(-3:3)
Base.IdentityUnitRange(-3:3)

julia> r[2]
2

julia> r[big(2)]
-2

@jishnub
Copy link
Contributor Author

jishnub commented Jun 14, 2021

Test failure seems unrelated

@jishnub
Copy link
Contributor Author

jishnub commented Jun 7, 2022

Gentle bump

@ViralBShah
Copy link
Member

Merge (after conflict resolution)?

@jishnub jishnub merged commit 6f8ba49 into JuliaLang:master Mar 9, 2024
5 of 7 checks passed
@jishnub jishnub deleted the indexIdentityUnitRange branch March 9, 2024 13:51
mkitti pushed a commit to mkitti/julia that referenced this pull request Apr 13, 2024
…tRange (JuliaLang#41224)

Adding these methods lets `OffsetArrays` define
`getindex(::AbstractUnitRange, ::IdentityUnitRange)` without
ambiguities. This is in the domain of sanctioned type-piracy, as the
result is an offset range in general and cannot be represented correctly
using `Base` types.

Re: JuliaArrays/OffsetArrays.jl#244

cc: @johnnychen94 

Edit: this also fixes an indexing bug in `IdentityUntiRange`:
master
```julia
julia> r = Base.IdentityUnitRange(-3:3)
Base.IdentityUnitRange(-3:3)

julia> r[2]
2

julia> r[big(2)]
-2
```

Co-authored-by: jishnub <jishnub@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

3 participants