Skip to content

time: Parse error messages may be confusing/misleading #56730

@extemporalgenome

Description

@extemporalgenome

What version of Go are you using (go version)?

$ go version
go version go1.19.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

https://go.dev/play/p/PUywlZ7-BE5

func main() {
	_, err := time.Parse("2006-01-02", "22-10-25")
	fmt.Println(err)
}

What did you expect to see?

parsing time "22-10-25" as "2006-01-02": cannot parse "22" as "2006"

What did you see instead?

parsing time "22-10-25" as "2006-01-02": cannot parse "0-25" as "2006"

It appears that this the parser is doing some blocking or chunking that gets misaligned in the error reporting when fewer than the expected number of digits appear in the input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions