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

Don't assume Int in _sametype in broadcasting #33391

Closed
dlfivefifty opened this issue Sep 26, 2019 · 5 comments
Closed

Don't assume Int in _sametype in broadcasting #33391

dlfivefifty opened this issue Sep 26, 2019 · 5 comments

Comments

@dlfivefifty
Copy link
Contributor

These lines are breaking InfiniteArrays.jl in Julia v1.0.5 (but not other v1.x or v1.0.x):

_sametype(a::OneTo, b::OneTo) = OneTo{Int}(a)

It seems like a bad idea to assume Int, as they may be BigInt. I can work around it but this should have been considered a breaking change.

@KristofferC
Copy link
Sponsor Member

Wasn't this put into 1.0.3?
#30074

@dlfivefifty
Copy link
Contributor Author

Ah, I only checked 1.0.2 and 1.0.5

@dlfivefifty
Copy link
Contributor Author

I realised the issue is with the call to UnitRange, not the use of Int. I need to hack around due to the nature of InfiniteArrays.jl, so from my perspective this issue can be closed.

However, I think the hard coding of Int is very suspicious, and it seems that it should be

_sametype(a::OneTo{T}, b::OneTo{V}) where {T,V} = OneTo{promote_type(T,V)}(a) 

@timholy
Copy link
Sponsor Member

timholy commented Sep 26, 2019

We default to Int for all scalar indexing operations:

julia> to_indices(rand(2), (0x01,))
(1,)

@dlfivefifty
Copy link
Contributor Author

OK, fair enough. In any case that code has been removed and I've fixed the issue in InfiniteArrays.jl. So I'll close this.

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

No branches or pull requests

3 participants