Skip to content

Fix for duplicate arguments bug 117 - #187

Merged
Taywee merged 2 commits into
Taywee:masterfrom
iWiggins:bug/117-duplicate_arguments
Jul 16, 2026
Merged

Fix for duplicate arguments bug 117#187
Taywee merged 2 commits into
Taywee:masterfrom
iWiggins:bug/117-duplicate_arguments

Conversation

@iWiggins

Copy link
Copy Markdown
Contributor

Fixes #117 by searching the tree for duplicate arguments on parse.

Normal context throws a ParseError if a duplicate is found.
Noexcept context sets a UsageError if a duplicate is found.

@Taywee

Taywee commented Jul 15, 2026

Copy link
Copy Markdown
Owner

The concept is fine by me, but the tests don't look right. Each executable looks like it defines 6 tests, but only calls two of them. The testDuplicateShortInTwoGroups examples actually duplicate long arguments (even though they aren't called).

The extra tests look useful. Those should be fixed and enabled.

@iWiggins

Copy link
Copy Markdown
Contributor Author

@Taywee Enabled the missing tests.

Comment thread test/detect_duplicate_flags.cxx Outdated
Comment thread test/detect_duplicate_flags.cxx Outdated
Comment thread test/detect_duplicate_flags.cxx Outdated
@iWiggins
iWiggins requested a review from Taywee July 16, 2026 07:11
@iWiggins
iWiggins force-pushed the bug/117-duplicate_arguments branch from 7aecf0d to 9f73245 Compare July 16, 2026 20:11
@iWiggins
iWiggins force-pushed the bug/117-duplicate_arguments branch from 9f73245 to cf563f6 Compare July 16, 2026 20:11
@iWiggins

Copy link
Copy Markdown
Contributor Author

Reworked the detection to occur when a flag is added, instead of on parsing.

@Taywee

Taywee commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Another implementation of this fix, #189, was recently opened as well. That looks like it might be a simpler implementation, but I don't see any evidence that it works across subgroups, and the testing here is more complete.

Edit: Actually, it does look like that one will probably work across subgroups, it's just not tested for yet.

@Taywee

Taywee commented Jul 16, 2026

Copy link
Copy Markdown
Owner

I poked at #189 a bit, and tried an approach merging this one and that one, and it looks like it's simple because to extend it to handle error-on-add, it would have to look pretty much exactly like this one.

@Taywee

Taywee commented Jul 16, 2026

Copy link
Copy Markdown
Owner

After these changes, I'm happy with the shape of it. Thanks for interfacing with me, and thanks for the PR.

@Taywee
Taywee merged commit 31bf603 into Taywee:master Jul 16, 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.

Supplying the same argument twice doesn't cause error

2 participants