Skip to content

getindex and isassigned with big BigInt ranges and trailing 1 indices errors #54786

Open
@mtfishman

Description

@mtfishman

isassigned with big BigInt ranges and trailing 1 indices fails with an InexactError:

julia> isassigned(1:big(10)^10, big(10)^10, 1)
true

julia> isassigned(1:big(10)^20, big(10)^20, 1)
ERROR: InexactError: Int64(100000000000000000000)
Stacktrace:
 [1] Type
   @ ./gmp.jl:384 [inlined]
 [2] convert
   @ ./number.jl:7 [inlined]
 [3] to_index
   @ ./indices.jl:292 [inlined]
 [4] to_index
   @ ./indices.jl:277 [inlined]
 [5] _to_indices1
   @ ./indices.jl:359 [inlined]
 [6] to_indices
   @ ./indices.jl:354 [inlined]
 [7] to_indices
   @ ./indices.jl:350 [inlined]
 [8] isassigned(::UnitRange{BigInt}, ::BigInt, ::Int64)
   @ Base ./multidimensional.jl:1568
 [9] top-level scope
   @ REPL[71]:1

julia> isassigned(1:big(10)^20, big(10)^20)
true

julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

I see the same issue on:

julia> versioninfo()
Julia Version 1.11.0-beta2
Commit edb3c92d6a6 (2024-05-29 09:37 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

and:

julia> versioninfo()
Julia Version 1.12.0-DEV.717
Commit f1c601ddbc0 (2024-06-12 23:50 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LLVM: libLLVM-17.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

It also doesn't seem to matter if the trailing index is big(1), it gives the same error.

EDIT: getindex also fails with the same error:

julia> (1:big(10)^20)[big(10)^20, 1]
ERROR: InexactError: Int64(100000000000000000000)
Stacktrace:
 [1] Type
   @ ./gmp.jl:384 [inlined]
 [2] convert
   @ ./number.jl:7 [inlined]
 [3] to_index
   @ ./indices.jl:292 [inlined]
 [4] to_index
   @ ./indices.jl:277 [inlined]
 [5] _to_indices1
   @ ./indices.jl:359 [inlined]
 [6] to_indices
   @ ./indices.jl:354 [inlined]
 [7] to_indices
   @ ./indices.jl:350 [inlined]
 [8] getindex(::UnitRange{BigInt}, ::BigInt, ::Int64)
   @ Base ./abstractarray.jl:1291
 [9] top-level scope
   @ REPL[74]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]bignumsBigInt and BigFloatrangesEverything AbstractRange

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions