Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/FixedSizeArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,12 @@ end
# `getindex` with a `Colon` for the index: better effects than with the generic fallback

function Base.getindex(a::FixedSizeArray, ::Colon)
copy(a)
c = copy(a)
if a isa AbstractVector
c
else
reshape(c, :)
end
end

# `copyto!`
Expand Down
11 changes: 10 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ end
m = FixedSizeArray(rand(2, 2))::FixedSizeArray
@test m == copy(m)
@test m !== copy(m)
@test m == m[:]
@test reshape(m, :) == m[:]
@test m !== m[:]
end

Expand Down Expand Up @@ -708,4 +708,13 @@ end
tuple(m...)
end[] == NTuple{3, Int}
end

@testset "getindex with a single colon must return an `AbstractVector`" begin
for m in 0:3
@test let a = FixedSizeArray{Float32}(undef, ntuple(Returns(1), m))
a::AbstractArray{<:Any, m}
a[:] isa AbstractVector
end
end
end
end