Skip to content

Commit 914de06

Browse files
authored
improve error when broadcast failed due to axistype (#45922)
1 parent 9aba4a8 commit 914de06

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

base/broadcast.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ end
520520
_bcs1(a::Integer, b::Integer) = a == 1 ? b : (b == 1 ? a : (a == b ? a : throw(DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths $a and $b"))))
521521
_bcs1(a::Integer, b) = a == 1 ? b : (first(b) == 1 && last(b) == a ? b : throw(DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths $a and $(length(b))")))
522522
_bcs1(a, b::Integer) = _bcs1(b, a)
523-
_bcs1(a, b) = _bcsm(b, a) ? axistype(b, a) : (_bcsm(a, b) ? axistype(a, b) : throw(DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths $(length(a)) and $(length(b))")))
523+
_bcs1(a, b) = _bcsm(b, a) ? axistype(b, a) : _bcsm(a, b) ? axistype(a, b) : throw(DimensionMismatch(LazyString("arrays could not be broadcast to a common size: a has axes ", a, " and b has axes ", b)))
524524
# _bcsm tests whether the second index is consistent with the first
525525
_bcsm(a, b) = a == b || length(b) == 1
526526
_bcsm(a, b::Number) = b == 1

0 commit comments

Comments
 (0)