Skip to content

Commit 164ff23

Browse files
authored
Fix reshape vector ambiguity (#313)
1 parent 20f2cfc commit 164ff23

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/FillArrays.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ end
264264
reshape(parent::AbstractFill, dims::Integer...) = reshape(parent, dims)
265265
reshape(parent::AbstractFill, dims::Union{Int,Colon}...) = reshape(parent, dims)
266266
reshape(parent::AbstractFill, dims::Union{Integer,Colon}...) = reshape(parent, dims)
267+
# resolve ambiguity with Base
268+
reshape(parent::AbstractFillVector, dims::Colon) = parent
267269

268270
reshape(parent::AbstractFill, dims::Tuple{Vararg{Union{Integer,Colon}}}) =
269271
fill_reshape(parent, Base._reshape_uncolon(parent, dims)...)
@@ -273,6 +275,10 @@ reshape(parent::AbstractFill, shp::Tuple{Union{Integer,Base.OneTo}, Vararg{Union
273275
reshape(parent, Base.to_shape(shp))
274276
reshape(parent::AbstractFill, dims::Dims) = Base._reshape(parent, dims)
275277
reshape(parent::AbstractFill, dims::Tuple{Integer, Vararg{Integer}}) = Base._reshape(parent, dims)
278+
279+
# resolve ambiguity with Base
280+
reshape(parent::AbstractFillVector, dims::Tuple{Colon}) = parent
281+
276282
Base._reshape(parent::AbstractFill, dims::Dims) = fill_reshape(parent, dims...)
277283
Base._reshape(parent::AbstractFill, dims::Tuple{Integer,Vararg{Integer}}) = fill_reshape(parent, dims...)
278284
# Resolves ambiguity error with `_reshape(v::AbstractArray{T, 1}, dims::Tuple{Int})`

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,8 @@ end
17621762
@test reshape(Zeros(6),big(2),3) == Zeros(big(2),3)
17631763
@test reshape(Fill(2,2,3),Val(1)) Fill(2,6)
17641764
@test reshape(Fill(2, 2), (2, )) Fill(2, 2)
1765+
1766+
@test reshape(Fill(2,3), :) === reshape(Fill(2,3), (:,)) === Fill(2,3)
17651767
end
17661768

17671769
@testset "lmul!/rmul!" begin

0 commit comments

Comments
 (0)