From 78035e1a4475b77f54964b3f9dd7ca6b92ac7f51 Mon Sep 17 00:00:00 2001 From: William Moses Date: Sun, 1 Dec 2024 12:49:10 -0500 Subject: [PATCH] Match base julia error messages for hvcat (#588) --- src/sparsevector.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sparsevector.jl b/src/sparsevector.jl index 751ffe6a..24cae01f 100644 --- a/src/sparsevector.jl +++ b/src/sparsevector.jl @@ -1243,6 +1243,15 @@ function hvcat_internal(rows::Tuple{Vararg{Int}}, X1::_SparseConcatGroup, X::_Sp if anysparse(X1) || anysparse(X...) vcat(_hvcat_rows(rows, X1, X...)...) else + # Needed to match error type with Base Julia. See https://github.com/JuliaLang/julia/pull/56543#issuecomment-2508637550 + matrix_len = if length(rows) == 0 + 0 + else + length(rows) * rows[1] + end + if matrix_len != 1 + length(X) + throw(ArgumentError("argument count does not match specified shape (expected $matrix_len, got $(1+length(X)))")) + end Base.typed_hvcat(Base.promote_eltypeof(X1, X...), rows, X1, X...) end end