Skip to content

fix: refresh sorted visits after flag normalization - #543

Closed
ViktorBystrov72 wants to merge 1 commit into
spf13:masterfrom
ViktorBystrov72:fix/flag-normalization-state
Closed

ViktorBystrov72 wants to merge 1 commit into
spf13:masterfrom
ViktorBystrov72:fix/flag-normalization-state

Conversation

@ViktorBystrov72

Copy link
Copy Markdown

FlagSet.Visit reuses its sorted cache after SetNormalizeFunc renames flags. If the new names sort differently, visits no longer follow the documented lexicographical order. For example, visiting middle,zulu, then aliasing zulu to alpha, produces middle,alpha instead of alpha,middle.

Invalidate the sorted set-flag cache alongside the existing declared-flag cache. The regression test populates the cache before normalization and checks both sorted visits and insertion-order visits, including an unset flag that must remain excluded.

Validation on macOS arm64 with Go 1.27.3:

  • The sorted regression fails on unchanged master with [middle alpha], then passes with this change.
  • go test -race -count=1 ./... passes.
  • Repository-configured golangci-lint run ./... (2.14.0) reports no issues.
  • gofmt and git diff --check pass.

The older Go versions in the CI matrix were not run locally; the change uses the module's existing Go 1.12-compatible syntax.

Signed-off-by: Виктор Быстров <anatema@bk.ru>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants