Skip to content

Commit

Permalink
remove unnecessary newline when printing BoundsError (JuliaLang#36138)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Jun 4, 2020
1 parent 865c636 commit 186c3bb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
1 change: 0 additions & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function showerror(io::IO, ex::BoundsError)
print(io, ": attempt to access ")
summary(io, ex.a)
if isdefined(ex, :i)
!isa(ex.a, AbstractArray) && print(io, "\n ")
print(io, " at index [")
if ex.i isa AbstractRange
print(io, ex.i)
Expand Down
12 changes: 4 additions & 8 deletions base/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,11 @@ julia> thisind("α", 3)
3
julia> thisind("α", 4)
ERROR: BoundsError: attempt to access String
at index [4]
ERROR: BoundsError: attempt to access String at index [4]
[...]
julia> thisind("α", -1)
ERROR: BoundsError: attempt to access String
at index [-1]
ERROR: BoundsError: attempt to access String at index [-1]
[...]
```
"""
Expand Down Expand Up @@ -468,8 +466,7 @@ julia> prevind("α", 1)
0
julia> prevind("α", 0)
ERROR: BoundsError: attempt to access String
at index [0]
ERROR: BoundsError: attempt to access String at index [0]
[...]
julia> prevind("α", 2, 2)
Expand Down Expand Up @@ -528,8 +525,7 @@ julia> nextind("α", 1)
3
julia> nextind("α", 3)
ERROR: BoundsError: attempt to access String
at index [3]
ERROR: BoundsError: attempt to access String at index [3]
[...]
julia> nextind("α", 0, 2)
Expand Down
6 changes: 2 additions & 4 deletions doc/src/manual/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,11 @@ Using an index less than `begin` (`1`) or greater than `end` raises an error:

```jldoctest helloworldstring
julia> str[begin-1]
ERROR: BoundsError: attempt to access String
at index [0]
ERROR: BoundsError: attempt to access String at index [0]
[...]
julia> str[end+1]
ERROR: BoundsError: attempt to access String
at index [15]
ERROR: BoundsError: attempt to access String at index [15]
[...]
```

Expand Down
4 changes: 2 additions & 2 deletions test/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,15 @@ let undefvar
@test occursin("DomainError with [0.0 -1.0 …", err_str)

err_str = @except_str (1, 2, 3)[4] BoundsError
@test err_str == "BoundsError: attempt to access (1, 2, 3)\n at index [4]"
@test err_str == "BoundsError: attempt to access (1, 2, 3) at index [4]"

err_str = @except_str [5, 4, 3][-2, 1] BoundsError
@test err_str == "BoundsError: attempt to access 3-element Array{$Int,1} at index [-2, 1]"
err_str = @except_str [5, 4, 3][1:5] BoundsError
@test err_str == "BoundsError: attempt to access 3-element Array{$Int,1} at index [1:5]"

err_str = @except_str Bounded(2)[3] BoundsError
@test err_str == "BoundsError: attempt to access 2-size Bounded\n at index [3]"
@test err_str == "BoundsError: attempt to access 2-size Bounded at index [3]"

err_str = @except_str 0::Bool TypeError
@test err_str == "TypeError: non-boolean ($Int) used in boolean context"
Expand Down

0 comments on commit 186c3bb

Please sign in to comment.