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

bugs involving IdentityUnitRange #54783

Open
matthias314 opened this issue Jun 12, 2024 · 2 comments
Open

bugs involving IdentityUnitRange #54783

matthias314 opened this issue Jun 12, 2024 · 2 comments
Labels
domain:ranges Everything AbstractRange

Comments

@matthias314
Copy link
Contributor

matthias314 commented Jun 12, 2024

The code in range.jl was presumably written under the assumption that all ranges (or all arrays) are 1-based. With IdentityUnitRange, this is not true anymore, and this leads to problems. I have found the following issues: For

u = 2:4
v = Base.IdentityUnitRange(2:4)
w = 1:9

one gets:

julia> axes(u) == axes(v), u == v     # equal arrays must have equal axes
(false, true)

julia> w[v][2], w[v[2]]     # the documentation defines w[v][i] to be w[v[i]]
(3, 2)

This happens with Julia 1.10.4, 1.11.0-beta2 and master.

EDIT: I've just noticed that while IdentityUnitRange has a docstring, it is not mentioned in the documentation. Maybe it is considered internal.

@jishnub
Copy link
Contributor

jishnub commented Jun 13, 2024

I don't think this is fixable without being somewhat breaking, see #30950

@matthias314
Copy link
Contributor Author

I'm not so sure. My understanding is that #30950 is about some weird results when broadcasting over 1-element arrays. For the moment I've looked more closely at comparisons of ranges. I don't see why this couldn't be changed, but of course I might miss something. To get a better idea, I've created the PR #54825. Maybe this way one can see better what would happen with such a change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:ranges Everything AbstractRange
Projects
None yet
Development

No branches or pull requests

3 participants