Skip to content

parseint_preamble bounds check fails for AbstractString #29451

@samoconnor

Description

@samoconnor

i <= ncodeunits(s) should be i <= endpos ?

julia/base/parse.jl

Lines 75 to 76 in 1a1d6b6

if c == '0' && i <= ncodeunits(s)
c, i = iterate(s,i)::Tuple{Char, Int}

When I do parse(Int, "0") where "0" is an AbstractString and ncodeunits > lastindex, i get this:
TypeError: in parseint_preamble, in typeassert, expected Tuple{Char,Int64}, got Nothing

1a1d6b6#r30713661

Monkeypatching parseint_preamble for my string type with i <= endpos seems to fix the problem.

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