Skip to content

Commit

Permalink
Fix size check of arrays when broadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Aug 1, 2024
1 parent 0e42a16 commit 42ed65d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function broadcast_mutability(x, op, args::Vararg{Any,N}) where {N}
return broadcast_mutability(typeof(x), op, typeof.(args)...)
end

_checked_size(s, x::AbstractArray) = length(x) == s
_checked_size(s, x::AbstractArray) = size(x) == s
_checked_size(::Any, ::Any) = true
_checked_size(::Any, ::Tuple{}) = true
function _checked_size(s, x::Tuple)
Expand All @@ -123,7 +123,8 @@ function broadcast_mutability(
op,
args::Vararg{Any,N},
) where {N}
if !_checked_size(length(x), args)::Bool
@show x, args
if !_checked_size(size(x), args)::Bool
return IsNotMutable()
end
return broadcast_mutability(typeof(x), op, typeof.(args)...)
Expand Down

0 comments on commit 42ed65d

Please sign in to comment.