Skip to content

Cannot reshape zero-dimensional arrays #26163

@mbauman

Description

@mbauman
julia> struct Z <: AbstractArray{Int,0}; end
       Base.size(::Z) = ()
       Base.getindex(::Z) = 0

julia> Z()
0-dimensional Z:
0

julia> reshape(Z(), 1)
ERROR: ArgumentError: Cannot call front on an empty tuple
Stacktrace:
 [1] _front at ./tuple.jl:101 [inlined]
 [2] front at ./tuple.jl:99 [inlined]
 [3] __reshape at ./reshapedarray.jl:165 [inlined]
 [4] _reshape at ./reshapedarray.jl:152 [inlined]
 [5] reshape at ./reshapedarray.jl:92 [inlined]
 [6] reshape(::Z, ::Int64) at ./reshapedarray.jl:95
 [7] top-level scope

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions