-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REPL doc lookup assumed ASCII for the given string #41594
Conversation
Original code assumed ASCII, but that's not true.
I'm pretty sure the indices |
A quick test shows this not to be the case: julia> "÷="[end-1]
ERROR: StringIndexError: invalid index [2], valid nearby indices [1]=>'÷', [3]=>'='
Stacktrace:
[1] string_index_err(s::String, i::Int64)
@ Base .\strings\string.jl:12
[2] getindex_continued(s::String, i::Int64, u::UInt32)
@ Base .\strings\string.jl:233
[3] getindex(s::String, i::Int64)
@ Base .\strings\string.jl:226
[4] top-level scope
@ REPL[1]:1 |
The byte index before a valid Char index may not be a valid Char index itself (except for single-byte encodings like ASCII). In this case, the character in front of Thanks for the quick review, did not know about |
I don't think it really matters. Someone can always follow the issue -> PR trail from the testset name if they are really interested. |
Fix #41589
Original code assumed ASCII, but that's not true. There may be other places in Base or an Stdlib where this happens, I'll grep and possibly open another PR if I find more.
Also, is there a better way to check whether something just doesn't throw? Checking the type of the returned value certainly seems like a way, but is of limited use for other code paths and kind of feels wrong...