Skip to content

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

Open
@KimlikDAO-bot

Description

@KimlikDAO-bot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions