Skip to content

fix: treat Object.prototype flag names as unknown options - #209

Open
SAY-5 wants to merge 1 commit into
npm:mainfrom
SAY-5:fix-prototype-flag-crash
Open

fix: treat Object.prototype flag names as unknown options#209
SAY-5 wants to merge 1 commit into
npm:mainfrom
SAY-5:fix-prototype-flag-crash

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 23, 2026

Copy link
Copy Markdown

Flag names that collide with Object.prototype members (--toString, --valueOf, --hasOwnProperty, --isPrototypeOf, --constructor, ...) were resolved through unguarded bracket lookups on the types, shorthands and abbrevs maps, so they returned inherited prototype functions instead of undefined. resolveShort then called .split on that function and threw TypeError: shorthands[arg].split is not a function.

This gates each of those map lookups on hasOwn (and only reads types[k] when the key is actually present) so such flags are handled like any other unknown option. --toString x now parses to { toString: true } with x left in remain, matching --foobar x.

References

Fixes #208

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5
SAY-5 requested a review from a team as a code owner August 23, 2026 06:52
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.

Crash on --toString/--valueOf flags: shorthands lookup hits Object.prototype (TypeError)

1 participant