Problems with optional chaining and nullish coalesce operators #1688
Labels
bug
Issues considered a bug
Ecma Incompatibility
Issues about Rhino being incompatible with the EcmaScript spec
Milestone
While working on #1684 me and my colleagues @0xe and @nabacg have discovered a few problems with the two newly implemented operators.
For the optional chaining
?.
we do not support the syntaxa?.[ expr ]
, which #1684 would fix.Also, while the original PR #1593 implemented partial support for optional function calling, i.e.
a.b?.()
works, it does not support properly other kind of function calls such asa?.()
ora[b]?.()
.For nullish coalesce operator
??
we have instead discovered that we "leak" some temporary state. In #1624 a fix was implemented so that something likef() ?? 42
would evaluatef()
just once by creating a temporary name. However, that temp name leaks out to the containing scope, i.e.:Furthermore, we can even overwrite variables:
Given the similarities between these operators and the problems and missing features, we are trying to come up with a single approach that works with all cases. We hope to submit a PR in the next few weeks to fix all of this.
The text was updated successfully, but these errors were encountered: