Skip to content

proposal: strconv: Teach UnquoteChar to distinguish unexpected EOF from syntax errors #19107

@navytux

Description

@navytux

I propose to make the following change:

teach strconv.UnquoteChar to return io.ErrUnexpectedError instead of strconv.ErrSyntax when it sees truncated but otherwise valid input.

This is needed to get proper error reporting in situations where UnquoteChar is used to decode input stream step by step: there if we see truncated version of valid character as input always returning ErrSyntax effectively blocks caller from determining what it was - a real syntax error or unexpected end of stream.

Since UnquoteChar is internally used by Unquote, but Unquote always operates on complete input, Unquote error behaviour should be preserved to return ErrSyntax in all cases.

CL which implements this change: https://go-review.googlesource.com/37052/

/cc @rsc, @robpike, @Sajmani, @minux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions