dillon1000/react
Commit
Browse files 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.
Changed paths5 files
First-parent comparisoncompiler/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 AddedPatch
Files changed
Rendering syntax-highlighted changes…