Skip to content

[Fix] guard toStringTag with correct ternary precedence#53

Merged
ljharb merged 2 commits into
inspect-js:mainfrom
deepview-autofix:deepview/70091bcab7
Apr 26, 2026
Merged

[Fix] guard toStringTag with correct ternary precedence#53
ljharb merged 2 commits into
inspect-js:mainfrom
deepview-autofix:deepview/70091bcab7

Conversation

@deepview-autofix

Copy link
Copy Markdown
Contributor

The inner ternary typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol' compared typeof (a string) against hasShammedSymbols (a boolean), so it was always false and the expression was a constant truthy 'symbol'. This defeated the sham-vs-native type validation; in a malformed Symbol sham where Symbol.toStringTag exists with the wrong type, downstream toStringTag in obj usage could misbehave.

ljharb and others added 2 commits April 24, 2026 16:19
The inner ternary `typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol'`
compared `typeof` (a string) against `hasShammedSymbols` (a boolean), so it was always
`false` and the expression was a constant truthy `'symbol'`. This defeated the
sham-vs-native type validation; in a malformed Symbol sham where `Symbol.toStringTag`
exists with the wrong type, downstream `toStringTag in obj` usage could misbehave.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com>
Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com>
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
@ljharb ljharb force-pushed the deepview/70091bcab7 branch 2 times, most recently from a37987f to ca16eec Compare April 24, 2026 23:30

@ljharb ljharb 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.

added a test, and updated the lint config to require typeof comparisons to always be to string literals.

@ljharb ljharb force-pushed the deepview/70091bcab7 branch from ca16eec to 012c719 Compare April 25, 2026 21:50
@ljharb ljharb merged commit 012c719 into inspect-js:main Apr 26, 2026
414 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