Skip to content
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

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

Closed
extemporalgenome opened this issue Nov 14, 2022 · 3 comments
Closed

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

extemporalgenome opened this issue Nov 14, 2022 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@extemporalgenome
Copy link
Contributor

extemporalgenome commented Nov 14, 2022

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.

@bcmills
Copy link
Contributor

bcmills commented Nov 15, 2022

Does this still reproduce at HEAD? @dsnet has landed a bunch of Parse fixes during the 1.20 development cycle.

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 15, 2022
@extemporalgenome
Copy link
Contributor Author

Unfortunately it's still an issue:

> ./bin/go version
go version devel go1.20-cb5534c1c6 Wed Nov 16 02:02:26 2022 +0000 linux/amd64
> ./bin/go run /tmp/timebug.go
parsing time "22-10-25" as "2006-01-02": cannot parse "0-25" as "2006"

@gopherbot
Copy link

Change https://go.dev/cl/450936 mentions this issue: time: set the correct value element of a parse error

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 17, 2022
@dmitshur dmitshur added this to the Go1.20 milestone Nov 17, 2022
@golang golang locked and limited conversation to collaborators Nov 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants