Skip to content

Commit

Permalink
Better error messages for getindex(::Number) (JuliaLang#46457)
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored Aug 23, 2022
1 parent 18fa383 commit f0b5556
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/number.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ keys(::Number) = OneTo(1)
getindex(x::Number) = x
function getindex(x::Number, i::Integer)
@inline
@boundscheck i == 1 || throw(BoundsError())
@boundscheck i == 1 || throw(BoundsError(x, i))
x
end
function getindex(x::Number, I::Integer...)
@inline
@boundscheck all(isone, I) || throw(BoundsError())
@boundscheck all(isone, I) || throw(BoundsError(x, I))
x
end
get(x::Number, i::Integer, default) = isone(i) ? x : default
Expand Down

0 comments on commit f0b5556

Please sign in to comment.