Skip to content

tryparse(Bool, " ") throws an error instead of returning nothing #42616

Closed
@DilumAluthge

Description

@DilumAluthge
julia> tryparse(Int, "") === nothing
true

julia> tryparse(Int, " ") === nothing
true

julia> tryparse(Bool, "") === nothing
true

julia> tryparse(Bool, " ")
ERROR: BoundsError: attempt to access 1-codeunit String at index [2]
Stacktrace:
 [1] checkbounds
   @ ./strings/basic.jl:216 [inlined]
 [2] codeunit
   @ ./strings/string.jl:102 [inlined]
 [3] getindex
   @ ./strings/string.jl:223 [inlined]
 [4] tryparse_internal(#unused#::Type{Bool}, sbuff::String, startpos::Int64, endpos::Int64, base::Int64, raise::Bool)
   @ Base ./parse.jl:197
 [5] #tryparse#456
   @ ./parse.jl:237 [inlined]
 [6] tryparse(::Type{Bool}, s::String)
   @ Base ./parse.jl:237
 [7] top-level scope
   @ REPL[4]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorstrings"Strings!"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions