dillon1000/react
Commit
Browse files Ensure valid mutable ranges for all scopes; fix ranges for context vars
Our current validation fails to detect some invalid cases of mutable ranges — namely, ranges that are fully or partially uninitialized, with start or start+end still set to zero. This PR fixes these cases, starting by validating that the ranges for _all_ reactive scopes are valid: start >= 1, and end <= (last instr id + 1). This exposed the invalid cases, which are also fixed here: * During AnalyzeFunctions, we need to reset identifier ranges and scopes when exiting an inner function. This has to happen *after* the effects have been translated to the function deps/context operands, in order for InferRefenceEffects to continue working on the outer function. Previously I did this at the start of InferReactiveScopeVariables, but that's insufficient bc the incorrect ranges could also influence InferMutableRanges. AnalyzeFunctions is the point at which we compute the ranges for identifiers in the inner function, so it's the most ideal place to clean those up so they don't influence the outer function. * In InferMutableLifetimes, we need to ensure that context variable identifiers end up with a mutable range starting where they are declared, and ending with their last assignment. We now track declarations and extend their mutable range to account for each reassignment.
Changed paths8 files
First-parent comparisoncompiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/visitors.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Inference/AnalyseFunctions.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Inference/InferMutableLifetimes.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-array-declaration-to-context-var.expect.md ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructure-object-declaration-to-context-var.expect.md ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hoisting-nested-const-declaration-2.expect.md ModifiedPatch
Files changed
Rendering syntax-highlighted changes…