Skip to content

Commit ae2ee2a

Browse files
committed
@nospecialize for string_index_err and StringIndexError
The fields of `StringIndexError` are abstractly typed, so there's no reason to specialize, I think. The change seems like it could prevent some invalidation on loading user code.
1 parent 5a2faa4 commit ae2ee2a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

base/strings/string.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@ An error occurred when trying to access `str` at index `i` that is not valid.
88
struct StringIndexError <: Exception
99
string::AbstractString
1010
index::Integer
11+
function StringIndexError((@nospecialize s::AbstractString), (@nospecialize i::Integer))
12+
new(s, i)
13+
end
14+
end
15+
function StringIndexError(str, ind)
16+
s = convert(AbstractString, str)
17+
i = convert(Integer, ind)
18+
StringIndexError(s, i)
1119
end
12-
@noinline string_index_err(s::AbstractString, i::Integer) =
20+
@noinline string_index_err((@nospecialize s::AbstractString), (@nospecialize i::Integer)) =
1321
throw(StringIndexError(s, Int(i)))
1422
function Base.showerror(io::IO, exc::StringIndexError)
1523
s = exc.string

0 commit comments

Comments
 (0)