Misleading result from getStaticValue()
when called on mutable const-declared variables
#192
Labels
getStaticValue()
when called on mutable const-declared variables
#192
Transferring this issue from mysticatea#10 as requested in mysticatea#10 (comment).
i don't currently use this library, and haven't verified that the issue still applies; i did skim the commit log, though, and didn't see anything related.
When
getStaticValue()
is called with a scope and encounters an identifier referring to a variable declared withconst
, it computes that variable's static value based on itsconst
declaration initializer only. If the variable is initialized to a mutable value, it can later be modified, resulting in the return value fromgetStaticValue()
not matching the variable's true value at time of use.Example:
Calling
getStaticValue()
on the Identifier nodemutable
on line 3 returns{value: {a: 1}}
, butmutable
's actual value is{a: 1, b: 2}
.This can also result in erroneously classifying identifiers as static. For example:
mutable
on line 3 is not static-valued, butgetStaticValue()
returns{value: {a: 1}}
.The text was updated successfully, but these errors were encountered: