dillon1000/react

Commit

Support assignment expressions in value blocks

Enables support for assignment expressions in value blocks (which includes in 
loop init/test/update blocks). This was pretty straightforward, the main changes 
are: 

* During PropagateScopeDependencies, we currently record scope reassignments 
based on `Identifier` object identity. In the case where a variable is 
reassigned in multiple control-flow paths of a value block, however, there can 
be multiple object identities. So we now de-dupe reassignments based on 
identifier id. 

* MergeOverlappingScopes now treats value blocks as regular blocks, allowing it 
to correctly merge scopes from the value with other scopes from the outer block. 

Otherwise this is mostly just lots of tests. Note that there is an outstanding 
todo, which is that we currently error for ternaries and logicals whose value is 
unused (eg `cond ? (x = 1) : null`). I'll address that in a follow-up.
Browse files
Changed paths22 files
First-parent comparison
M compiler/forget/.eslintrc.js ModifiedM compiler/forget/src/HIR/BuildHIR.ts ModifiedM compiler/forget/src/ReactiveScopes/MergeOverlappingReactiveScopes.ts ModifiedM compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts ModifiedA compiler/forget/src/__tests__/fixtures/compiler/ternary-assignment-expression.expect.md AddedM compiler/forget/src/__tests__/fixtures/compiler/ternary-assignment-expression.js ModifiedM compiler/forget/src/__tests__/fixtures/compiler/while-logical.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/compiler/while-logical.js ModifiedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-destruction-with-mutation.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-destruction-with-mutation.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-destruction.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-destruction.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-with-mutation.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-with-mutation.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-ternary-with-mutation.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-ternary-with-mutation.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-ternary.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-ternary.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-with-mutation.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-with-mutation.js Added
Patch

Files changed

Rendering syntax-highlighted changes…