JuliaArrays / FillArrays.jl

Julia package for lazily representing matrices filled with a single entry
https://juliaarrays.github.io/FillArrays.jl/
MIT License
181 stars 39 forks source link

`reshape` error on Julia master #373

Open matthias314 opened 3 weeks ago

matthias314 commented 3 weeks ago

I discovered the following issue with the OffsetArrays tests, see JuliaArrays/OffsetArrays.jl#353. @nsajko suggested that I report it here and mention JuliaLang/julia#54261. The error happens both with FillArrays v1.11.0 and master:

julia> using FillArrays

julia> reshape(Fill(2,6), big(2), :)
ERROR: TypeError: in typeassert, expected Tuple{Vararg{Int64}}, got a value of type Tuple{BigInt}
Stacktrace:
 [1] _reshape_uncolon
   @ ./reshapedarray.jl:135 [inlined]
 [2] reshape(parent::Fill{Int64, 1, Tuple{Base.OneTo{Int64}}}, dims::Tuple{BigInt, Colon})
   @ FillArrays ~/.julia/packages/FillArrays/Zr8Pf/src/FillArrays.jl:269
 [3] reshape(::Fill{Int64, 1, Tuple{Base.OneTo{Int64}}}, ::BigInt, ::Colon)
   @ FillArrays ~/.julia/packages/FillArrays/Zr8Pf/src/FillArrays.jl:265
 [4] top-level scope
   @ REPL[4]:1
Julia Version 1.12.0-DEV.1053
Commit 6916eb74205 (2024-08-15 23:07 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 24 × Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, sandybridge)
Threads: 1 default, 0 interactive, 1 GC (on 24 virtual cores)
nsajko commented 3 weeks ago

FTR, it's usually better to move an existing issue to the proper repo, than to create a new one. That's what I was asking for. Someone who's a member of JuliaArrays should be able to do that. Not that it matters much now.

matthias314 commented 3 weeks ago

Sorry, didn't know that!

jishnub commented 3 weeks ago

I think reshape in Base should handle all Integers, and not just Ints. In that case, we won't need to define these specialized methods here at all.

nsajko commented 3 weeks ago

I agree. While looking into fixing this, I stumbled upon many open tickets for reshape on Julia's issue tracker, which seem like they should somewhat be considered together. E.g.:

https://github.com/JuliaLang/julia/issues/17372

https://github.com/JuliaLang/julia/issues/27474

https://github.com/JuliaLang/julia/issues/39123

https://github.com/JuliaLang/julia/issues/39951

https://github.com/JuliaLang/julia/issues/40076

https://github.com/JuliaLang/julia/issues/45589

It's a bit overwhelming TBH.

dlfivefifty commented 3 weeks ago

Is this bug also in Julia v1.11-rc?

I think it’s a mistake to try to support master as it’s always too much of a moving target

nsajko commented 3 weeks ago

The bug is that FillArrays relies on internal Julia functionality, _reshape_uncolon from Base, specifically. This is independent of Julia version, clearly.

It only manifests on nightly, though.