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

Object.keys() @nosideeffects semantics is not applied consistently #4218

Open
KimlikDAO-bot opened this issue Feb 9, 2025 · 1 comment
Open

Comments

@KimlikDAO-bot
Copy link
Contributor

KimlikDAO-bot commented Feb 9, 2025

In certain cases, unused Object.keys() is not elided.

Consider

Object.keys({
  "a": 1,
  "b": 2,
});

google-closure-compiler --js a.js -O ADVANCED outputs [JSC_USELESS_CODE] however

const a = Object.keys({
  "a": 1,
  "b": 2,
});

google-closure-compiler --js a.js -O ADVANCED outputs Object.keys({a:1,b:2});

Namely assigning an Object.keys() to an unused variable leads to elimination of the variable but not the method call.

The externs definition seems correct but something else is interfering.

@trevorade
Copy link
Contributor

Thank you for the report! We'll take a look at this when we can.

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

No branches or pull requests

2 participants