Skip to content

Commit

Permalink
Fix a bug in stack's DimensionMismatch error message (#54033)
Browse files Browse the repository at this point in the history
`stack` does not require that the inner iterator defines `axes`, but the
code to assemble an error message assumed this.

Found here:
https://discourse.julialang.org/t/reduce-hcat-is-type-unstable/112800/3
  • Loading branch information
mcabbott authored Jul 25, 2024
1 parent 0ffbae8 commit ae483c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3007,7 +3007,7 @@ end
@inline function _stack_size_check(x, ax1::Tuple)
if _iterator_axes(x) != ax1
uax1 = map(UnitRange, ax1)
uaxN = map(UnitRange, axes(x))
uaxN = map(UnitRange, _iterator_axes(x))
throw(DimensionMismatch(
LazyString("stack expects uniform slices, got axes(x) == ", uaxN, " while first had ", uax1)))
end
Expand Down
3 changes: 3 additions & 0 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,9 @@ end
@test_throws ArgumentError stack([1:3, 4:6]; dims=3)
@test_throws ArgumentError stack(abs2, 1:3; dims=2)

@test stack(["hello", "world"]) isa Matrix{Char}
@test_throws DimensionMismatch stack(["hello", "world!"]) # had a bug in error printing

# Empty
@test_throws ArgumentError stack(())
@test_throws ArgumentError stack([])
Expand Down

2 comments on commit ae483c3

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

Please sign in to comment.