dillon1000/react

Commit

More accurately model nested OptionalCallExpression

More accurately models nested OptionalCallExpression. Consider: 

```javascript 

a?.(b)?.(c) 

``` 

Our previous representation modeled it such that we treated the second function 
call as if it would be called regardless of whether `a` existed or not. We knew 
that the second call was conditional, so our test output was correct, but the 
control-flow graph didn't faithfully model the semantics. That bothered me. 

The new representation correctly models the control flow, and the fact that if 
`a` is null/undefined execution immediately aborts (not reaching the second call 
at all, nor the evaluation of its args), and evaluates the whole outer 
OptionalCallExpression to `undefined`. 

Note that nested optional member expressions still have the previous model — 
that's next to address.
Browse files
Changed paths5 files
First-parent comparison
M compiler/forget/src/HIR/BuildHIR.ts ModifiedM compiler/forget/src/__tests__/fixtures/compiler/optional-call-chained.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/compiler/optional-call-chained.js ModifiedA compiler/forget/src/__tests__/fixtures/compiler/optional-call-with-optional-property-load.expect.md AddedA compiler/forget/src/__tests__/fixtures/compiler/optional-call-with-optional-property-load.js Added
Patch

Files changed

Rendering syntax-highlighted changes…