<p dir="auto"><code class="notranslate">CartesianIndices</code> seems to enforce <code class="notranslate">Int</code> even if the arguments are of a different type; e.g.,</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="x = Int32(3)
@show typeof(-x:x)
# =&gt;  UnitRange{Int32}
c = CartesianIndices((-x:x, -x:x))
@show typeof(c.indices[1]) 
# =&gt; UnitRange{Int64}"><pre class="notranslate"><code class="notranslate">x = Int32(3)
@show typeof(-x:x)
# =&gt;  UnitRange{Int32}
c = CartesianIndices((-x:x, -x:x))
@show typeof(c.indices[1]) 
# =&gt; UnitRange{Int64}
</code></pre></div>
<p dir="auto">This is very bad for writing type-stable code that uses an integer type other than <code class="notranslate">Int</code>.</p>
<p dir="auto"><code class="notranslate">versioninfo()</code> -&gt;</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Julia Version 1.1.0
Commit 80516ca202* (2019-01-21 21:24 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.2.0)
  CPU: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 1"><pre class="notranslate"><code class="notranslate">Julia Version 1.1.0
Commit 80516ca202* (2019-01-21 21:24 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.2.0)
  CPU: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 1
</code></pre></div>
<p dir="auto">Due to <code class="notranslate">LinearIndices</code> only supporting <code class="notranslate">Int</code>s, <code class="notranslate">keys</code> and <code class="notranslate">LinearIndices</code> do not work when the indices are not representable as <code class="notranslate">Int</code>s:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; keys(1:typemax(Int128))
ERROR: InexactError: trunc(Int64, 170141183460469231731687303715884105727)
[...]

julia&gt; LinearIndices(1:typemax(Int128))
ERROR: InexactError: trunc(Int64, 170141183460469231731687303715884105727)
[...]"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">keys</span>(<span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">typemax</span>(Int128))
ERROR<span class="pl-k">:</span> InexactError<span class="pl-k">:</span> <span class="pl-c1">trunc</span>(Int64, <span class="pl-c1">170141183460469231731687303715884105727</span>)
[<span class="pl-k">...</span>]

julia<span class="pl-k">&gt;</span> <span class="pl-c1">LinearIndices</span>(<span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">typemax</span>(Int128))
ERROR<span class="pl-k">:</span> InexactError<span class="pl-k">:</span> <span class="pl-c1">trunc</span>(Int64, <span class="pl-c1">170141183460469231731687303715884105727</span>)
[<span class="pl-k">...</span>]</pre></div>
<p dir="auto">Related: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="322622328" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/27090" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/27090/hovercard" href="https://github.com/JuliaLang/julia/issues/27090">#27090</a></p>