dillon1000/react

Commit

[hir] implement nullish coalescing operator

This currently basically lowers the code into the equivalent of 

``` 

const vLeft = <left>; 

const vNull = null; 

const vCond = vLeft != vNull; 

vCond ? vLeft : <right> 

``` 

I created a temporary `Place` to hold the `null` constant value because the 
binary operator in HIR accepts only `Place`s. Not sure if this is the preferred 
approach. Alternatives I could think of: 

-  Allow constants as an alternative to Place? 

- A `NotNull` operator for `<x> != null` 

- Some other extension to the HIR?
Browse files
Changed paths4 files
First-parent comparison
M compiler/forget/src/HIR/BuildHIR.ts ModifiedM compiler/forget/src/HIR/InferReferenceEffects.ts ModifiedA compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/logical-expression.js Added
Patch

Files changed

Rendering syntax-highlighted changes…