# Index type of UnitRange{BigInt} changed from Int to BigInt after Julia 1.8: regression?

**URL:** <https://discourse.julialang.org/t/index-type-of-unitrange-bigint-changed-from-int-to-bigint-after-julia-1-8-regression/92199>\
**Category:** Internals & Design\
**Created:** [December 27, 2022, 8:59pm UTC](https://discourse.julialang.org/t/index-type-of-unitrange-bigint-changed-from-int-to-bigint-after-julia-1-8-regression/92199 "2022-12-27T20:59:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [December 27, 2022, 8:59pm UTC](https://discourse.julialang.org/t/index-type-of-unitrange-bigint-changed-from-int-to-bigint-after-julia-1-8-regression/92199/1 "2022-12-27T20:59:15Z")

</div>

This expression returns `Int` on Julia 1.8, but `BigInt` beyond Julia 1.8:

```julia
typeof(firstindex(map(BigInt, 1:1)))

```

I think this might be a regression, but it seems like it could also have been done on purpose?

This is arguably inconsistent with the behavior of:

```julia
typeof(firstindex(BigInt[10, 20]))

```

Personally I don’t really see why would a `BigInt` type for indices be necessary, it’s not like the indexing base/offset will be some huge number. In fact, the offset is fixed at one!

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 27, 2022, 9:03pm UTC](https://discourse.julialang.org/t/index-type-of-unitrange-bigint-changed-from-int-to-bigint-after-julia-1-8-regression/92199/2 "2022-12-27T21:03:39Z")

</div>

> [@nsajko](#):
>
> Personally I don’t really see why would a `BigInt` type for indices be necessary,

How would you access `a[end]` for `a = 1:big(10)^300` without a `BigInt` index?

I know that @dlfivefifty worked a lot on related issues (e.g. [Fixes for non-Int based lengths by dlfivefifty · Pull Request #37741 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/37741)), so may be he can comment more on when and why this change occurred.

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [December 27, 2022, 9:10pm UTC](https://discourse.julialang.org/t/index-type-of-unitrange-bigint-changed-from-int-to-bigint-after-julia-1-8-regression/92199/3 "2022-12-27T21:10:13Z")

</div>

You’ve definitely got a point. On the other hand, maybe `UnitRange` isn’t quite the right type for that kind of thing? I think that breaking assumptions about the index type being `Int` stands to make writing efficient code more complicated, because now I have to explicitly cast my indices to `Int` from `BigInt`. And `BigInt` isn’t even a pure-Julia type, inhibiting Julia’s inference capabilities and affecting performance.

I mean, why would someone use `1:big(10)^300` instead of just writing a short anonymous function?

---

<div class="post-metadata">

**Author:** ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Post date:** [December 28, 2022, 2:15pm UTC](https://discourse.julialang.org/t/index-type-of-unitrange-bigint-changed-from-int-to-bigint-after-julia-1-8-regression/92199/4 "2022-12-28T14:15:39Z")

</div>

LazyArrays.jl supports lazy manipulations of such arrays, something an anonymous function can’t do. One can use such big arrays to do some combinatorial calculations, eg you can take a `sum`.

Though the real reason for this was to support InfiniteArrays.jl and InfiniteLinearAlgebra.jl.
