Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs in negated in expressions #5800

Closed
gorosgobe opened this issue Sep 20, 2023 · 0 comments
Closed

Bugs in negated in expressions #5800

gorosgobe opened this issue Sep 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@gorosgobe
Copy link

What version of Bun is running?

No response

What platform is your computer?

No response

What steps can reproduce the bug?

in and instanceof expressions in JS

a in obj;
a instanceof C;

can be negated by grouping them and applying the ! operator, i.e.

!(a in obj);
!(a instanceof C);

Applying the ! operator incorrectly (on the LHS operand) leads to bugs:

!a in obj; // will evaluate to false, unless obj has a "true" or "false" key
!a instanceof C; // will evaluate to false, unless C overrides instanceof with a @@hasInstance method

For more information, please see these MDN docs and the no-unsafe-negation recommended Eslint rule.

I have found a potentially problematic instance of the above bugs in your codebase:

if (!"TZ" in process.env) {

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

@gorosgobe gorosgobe added the bug Something isn't working label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant