Skip to content

Commit

Permalink
Tighten typechecking in repeat to match what's documented (#55444)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott authored Nov 11, 2024
1 parent f93138e commit ad24368
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ad24368

Please sign in to comment.