Skip to content

test: add regression for non-count option with value 1#534

Closed
ZhouYinLong-lab wants to merge 1 commit into
yargs:mainfrom
ZhouYinLong-lab:test/add-count-value-1-regression
Closed

test: add regression for non-count option with value 1#534
ZhouYinLong-lab wants to merge 1 commit into
yargs:mainfrom
ZhouYinLong-lab:test/add-count-value-1-regression

Conversation

@ZhouYinLong-lab

Copy link
Copy Markdown

What changed

Added a regression test for non-count options that receive a value of 1.

Why

When passing -x 3 -x 1, the parser incorrectly treats the 1 as a count increment, returning x: 4 instead of x: [3, 1]. The root cause is in setKey() where value === increment() (which is 1) gates the increment logic, incorrectly matching actual values of 1.

Verification

parser("-x 3 -x 1")
// Expected: x: [3, 1]
// Actual:   x: 4  ← bug: 3 + 1 = 4

The test currently fails as expected.

Related issue

Refs #506

@shadowspawn

shadowspawn commented Jul 6, 2026

Copy link
Copy Markdown
Member
  1. This looks like AI slop
  2. These is already an open PR fix(setKey): use a sentinel to detect count auto-increment #529

@shadowspawn shadowspawn closed this Jul 6, 2026
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