Skip to content

Commit bc33a3e

Browse files
nsajkoaviatesk
andauthored
@nospecialize for string_index_err (#57604)
The fields of `StringIndexError` are abstractly typed, so there's no reason to specialize on a concrete type. The change seems like it could prevent some invalidation on loading user code. --------- Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
1 parent fc0017f commit bc33a3e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

base/strings/string.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ An error occurred when trying to access `str` at index `i` that is not valid.
77
"""
88
struct StringIndexError <: Exception
99
string::AbstractString
10-
index::Integer
10+
index::Int
1111
end
12-
@noinline string_index_err(s::AbstractString, i::Integer) =
12+
@noinline string_index_err((@nospecialize s::AbstractString), i::Integer) =
1313
throw(StringIndexError(s, Int(i)))
1414
function Base.showerror(io::IO, exc::StringIndexError)
1515
s = exc.string

0 commit comments

Comments
 (0)