Repository navigation
Conversation
|
|
xiangnuans
left a comment
There was a problem hiding this comment.
I independently checked a direct transition from an input containing -- to an empty reparse on Go 1.27.4 (Darwin arm64):
- Parse
[]string{"before", "--", "after"}on a newFlagSetand check thatArgsLenAtDash()is1. - Call
Parse(nil)on that sameFlagSetand expectArgsLenAtDash()to be-1.
The new check fails on master at 45c23e5 (returns 1) and passes on this PR at 9453208, alongside go test -count=1 ./.... I also temporarily moved the reset below the empty-input early return: TestParseRepeated still passed, while the new check failed. The current empty subtest starts after a parse without a delimiter, so the previous call has already cleared the value.
Could the empty-input subtest start right after a parse with --, or seed the delimiter again before calling Parse(nil)? That would protect the placement of the reset. The current implementation already passes this case.
AI-assisted review. The test results above are from local execution.
|
Thanks for checking the placement. I added a subtest that parses |
ParseandParseAllnow reset the stored--position before each argument list, so reusing aFlagSetcannot return a staleArgsLenAtDash()value. Regression coverage exercises a first parse with--, followed by parses without it and with no arguments, and covers both parsing entry points.Tests:
go test -race ./...;golangci-lint run ./...Fixes #538