Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slightly less bad error messages for promote_shape #33567

Merged
merged 1 commit into from
Oct 16, 2019
Merged
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
14 changes: 7 additions & 7 deletions base/indices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ promote_shape(::Tuple{}, ::Tuple{}) = ()

function promote_shape(a::Tuple{Int,}, b::Tuple{Int,})
if a[1] != b[1]
throw(DimensionMismatch("dimensions must match"))
throw(DimensionMismatch("dimensions must match: a has dims $a, b has dims $b"))
end
return a
end

function promote_shape(a::Tuple{Int,Int}, b::Tuple{Int,})
if a[1] != b[1] || a[2] != 1
throw(DimensionMismatch("dimensions must match"))
throw(DimensionMismatch("dimensions must match: a has dims $a, b has dims $b"))
end
return a
end
Expand All @@ -124,7 +124,7 @@ promote_shape(a::Tuple{Int,}, b::Tuple{Int,Int}) = promote_shape(b, a)

function promote_shape(a::Tuple{Int, Int}, b::Tuple{Int, Int})
if a[1] != b[1] || a[2] != b[2]
throw(DimensionMismatch("dimensions must match"))
throw(DimensionMismatch("dimensions must match: a has dims $a, b has dims $b"))
end
return a
end
Expand Down Expand Up @@ -154,12 +154,12 @@ function promote_shape(a::Dims, b::Dims)
end
for i=1:length(b)
if a[i] != b[i]
throw(DimensionMismatch("dimensions must match"))
throw(DimensionMismatch("dimensions must match: a has dims $a, b has dims $b, mismatch at $i"))
end
end
for i=length(b)+1:length(a)
if a[i] != 1
throw(DimensionMismatch("dimensions must match"))
throw(DimensionMismatch("dimensions must match: a has dims $a, must have singleton at dim $i"))
end
end
return a
Expand All @@ -175,12 +175,12 @@ function promote_shape(a::Indices, b::Indices)
end
for i=1:length(b)
if a[i] != b[i]
throw(DimensionMismatch("dimensions must match"))
throw(DimensionMismatch("dimensions must match: a has dims $a, b has dims $b, mismatch at $i"))
end
end
for i=length(b)+1:length(a)
if a[i] != 1:1
throw(DimensionMismatch("dimensions must match"))
throw(DimensionMismatch("dimensions must match: a has dims $a, must have singleton at dim $i"))
end
end
return a
Expand Down