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

Misleading result from getStaticValue() on expressions that re-use Symbol()s #12

Closed
ninevra opened this issue Aug 27, 2020 · 0 comments · Fixed by #13
Closed

Misleading result from getStaticValue() on expressions that re-use Symbol()s #12

ninevra opened this issue Aug 27, 2020 · 0 comments · Fixed by #13

Comments

@ninevra
Copy link
Contributor

ninevra commented Aug 27, 2020

Example:

const symbol = Symbol();
(symbol === symbol); // <--

The value of the expression on line 2 is true, but getStaticValue() returns {value: false}.

This is probably because the two recursive calls to getStaticValueR() (evaluating the left and right sides of the BinaryExpression) both invoke Symbol() and so both return different Symbols.

This could be resolved either by removing Symbol from callAllowed or by caching the static values of Identifiers encountered during recursion. However, the latter approach would still produce strange results if the user compared the returned static values of, for example, two different references to const symbol = Symbol();.

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

Successfully merging a pull request may close this issue.

1 participant