From ad243681bddad93d4b700d1417e0d45d00a31fc1 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:21:59 -0500 Subject: [PATCH] Tighten typechecking in `repeat` to match what's documented (#55444) --- base/abstractarraymath.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index 0f028a0f66729..54b6d75cee2dc 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -518,6 +518,9 @@ function check(arr, inner, outer) # TODO: Currently one based indexing is demanded for inner !== nothing, # but not for outer !== nothing. Decide for something consistent. Base.require_one_based_indexing(arr) + if !all(n -> n isa Integer, inner) + throw(ArgumentError("repeat requires integer counts, got inner = $inner")) + end if any(<(0), inner) throw(ArgumentError("no inner repetition count may be negative; got $inner")) end @@ -526,6 +529,9 @@ function check(arr, inner, outer) end end if outer !== nothing + if !all(n -> n isa Integer, outer) + throw(ArgumentError("repeat requires integer counts, got outer = $outer")) + end if any(<(0), outer) throw(ArgumentError("no outer repetition count may be negative; got $outer")) end