You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix crash in IsolatePolyfills pass with optional chaining
The IsolatePolyfills pass (run during stage 3 finalization) loses the optional chaining operator when rewriting the polyfill usages and produces code that crashes on the ASTValidator.
For example, it rewrites the usage of "includes" below:
```
a.b()?.includes();
```
into
```
var $jscomp$polyfillTmp = a.b();
$jscomp$lookupPolyfilledValue($jscomp$polyfillTmp,"includes").call($jscomp$polyfillTmp);
```
which loses the optional chain and crashes the ASTValidator.
```
java.lang.IllegalStateException: Start of optional chain node OPTCHAIN_CALL is not marked as the start..
```
This CL changes the rewriting to produce:
```
var $jscomp$polyfillTmp = a.b();
$jscomp$lookupPolyfilledValue($jscomp$polyfillTmp,"includes", isOptChainAccess)?.call($jscomp$polyfillTmp);
```
This also fixes the ASTValidator crash by preserving the `START_OF_OPT_CHAIN` property on the lhs of `?.` to indicate the start of the optional chain.
PiperOrigin-RevId: 511875065
0 commit comments