Skip to content

scope duplicate-flag detection to command boundaries - #191

Merged
Taywee merged 1 commit into
Taywee:masterfrom
metsw24-max:duplicate-flags-command-scope
Jul 20, 2026
Merged

scope duplicate-flag detection to command boundaries#191
Taywee merged 1 commit into
Taywee:masterfrom
metsw24-max:duplicate-flags-command-scope

Conversation

@metsw24-max

Copy link
Copy Markdown
Contributor

False duplicate error across command boundaries

Duplicate detection shares one used-flag set as it walks the tree, and since a command keeps parent == nullptr it acts as its own detection root. Declaring a flag inside a command and then a same-named flag in a parent scope (say run's -m followed by a top-level -m) is rejected as a duplicate even though the two live in separate namespaces; the reverse declaration order and reuse between sibling commands are already accepted, so the behaviour is order dependent. Guarding the descent with IsGroup(), which is false for a command, keeps detection within a single scope while genuine duplicates in the parser, a group, or one command are still caught. The added tests fail on master and pass with the change.

@Taywee

Taywee commented Jul 20, 2026

Copy link
Copy Markdown
Owner

I was a bit worried about this possible edge case. I probably should have asked for this to be covered by tests in the original PR.

Thanks for the fix.

@Taywee
Taywee merged commit 432d36b into Taywee:master Jul 20, 2026
7 checks passed
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