Skip to content

Commit

Permalink
Fix reshape vector ambiguity
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Dec 1, 2023
1 parent b6fa0b4 commit a335fd1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ end
reshape(parent::AbstractFill, dims::Integer...) = reshape(parent, dims)
reshape(parent::AbstractFill, dims::Union{Int,Colon}...) = reshape(parent, dims)
reshape(parent::AbstractFill, dims::Union{Integer,Colon}...) = reshape(parent, dims)
# resolve ambiguity with Base
reshape(parent::AbstractFillVector, dims::Colon) = parent

reshape(parent::AbstractFill, dims::Tuple{Vararg{Union{Integer,Colon}}}) =
fill_reshape(parent, Base._reshape_uncolon(parent, dims)...)
Expand All @@ -273,6 +275,10 @@ reshape(parent::AbstractFill, shp::Tuple{Union{Integer,Base.OneTo}, Vararg{Union
reshape(parent, Base.to_shape(shp))
reshape(parent::AbstractFill, dims::Dims) = Base._reshape(parent, dims)
reshape(parent::AbstractFill, dims::Tuple{Integer, Vararg{Integer}}) = Base._reshape(parent, dims)

# resolve ambiguity with Base
reshape(parent::AbstractFillVector, dims::Tuple{Colon}) = parent

Base._reshape(parent::AbstractFill, dims::Dims) = fill_reshape(parent, dims...)
Base._reshape(parent::AbstractFill, dims::Tuple{Integer,Vararg{Integer}}) = fill_reshape(parent, dims...)
# Resolves ambiguity error with `_reshape(v::AbstractArray{T, 1}, dims::Tuple{Int})`
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,8 @@ end
@test reshape(Zeros(6),big(2),3) == Zeros(big(2),3)
@test reshape(Fill(2,2,3),Val(1)) Fill(2,6)
@test reshape(Fill(2, 2), (2, )) Fill(2, 2)

@test reshape(Fill(2,3), :) === reshape(Fill(2,3), (:,)) === Fill(2,3)
end

@testset "lmul!/rmul!" begin
Expand Down

0 comments on commit a335fd1

Please sign in to comment.