Skip to content

Commit ad24368

Browse files
authored
Tighten typechecking in repeat to match what's documented (#55444)
1 parent f93138e commit ad24368

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

base/abstractarraymath.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,9 @@ function check(arr, inner, outer)
518518
# TODO: Currently one based indexing is demanded for inner !== nothing,
519519
# but not for outer !== nothing. Decide for something consistent.
520520
Base.require_one_based_indexing(arr)
521+
if !all(n -> n isa Integer, inner)
522+
throw(ArgumentError("repeat requires integer counts, got inner = $inner"))
523+
end
521524
if any(<(0), inner)
522525
throw(ArgumentError("no inner repetition count may be negative; got $inner"))
523526
end
@@ -526,6 +529,9 @@ function check(arr, inner, outer)
526529
end
527530
end
528531
if outer !== nothing
532+
if !all(n -> n isa Integer, outer)
533+
throw(ArgumentError("repeat requires integer counts, got outer = $outer"))
534+
end
529535
if any(<(0), outer)
530536
throw(ArgumentError("no outer repetition count may be negative; got $outer"))
531537
end

0 commit comments

Comments
 (0)