Skip to content

fix: use a sentinel to detect count auto-increment - #529

Merged
shadowspawn merged 4 commits into
yargs:mainfrom
SAY-5:fix/count-sentinel
Oct 10, 2026
Merged

shadowspawn merged 4 commits into
yargs:mainfrom
SAY-5:fix/count-sentinel

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 13, 2026

Copy link
Copy Markdown
Contributor

The TypeScript conversion changed value === increment (function reference used as a sentinel) to value === increment() (which returns 1), so any later occurrence of a non-count argument with value 1 is incorrectly incremented onto the previous value (parser('-x 3 -x 1') returns { x: 4 } instead of { x: [3, 1] }). Restored the original semantics with a Symbol sentinel that flows from processValue to setKey.

Closes #506

@shadowspawn

Copy link
Copy Markdown
Member

To be clear: is this PR entirely AI/LLM generated?

@SAY-5

SAY-5 commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

No. I traced the regression from #506 myself, confirmed the sentinel-reference behavior change in git history, and verified the Symbol fix against the failing case with the added test. Happy to walk through any part of the reasoning.

@shadowspawn shadowspawn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shadowspawn shadowspawn changed the title fix(setKey): use a sentinel to detect count auto-increment fix: use a sentinel to detect count auto-increment Oct 10, 2026
@shadowspawn
shadowspawn merged commit add38aa into yargs:main Oct 10, 2026
8 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.

Multiple arguments are incremented if they are equal to 1.

2 participants