-
-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
bugSomething isn't workingSomething isn't working
Description
When getStaticValue() is called with a scope and encounters an identifier referring to a variable declared with const, it computes that variable's static value based on its const declaration initializer only. If the variable is initialized to a mutable value, it can later be modified, resulting in the return value from getStaticValue() not matching the variable's true value at time of use.
Example:
const mutable = {a: 1};
mutable.b = 2;
mutable;Calling getStaticValue() on the Identifier node mutable on line 3 returns {value: {a: 1}}, but mutable's actual value is {a: 1, b: 2}.
This can also result in erroneously identifying identifiers as static. For example:
const mutable = {a: 1};
mutable.b = foo();
mutable;mutable on line 3 is not static-valued, but getStaticValue() returns {value: {a: 1}}.
sindresorhus and liangyuanruo
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working