mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
91f7bc8be7837ded7664220a30e447a8aae5b87b
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.
Description
Languages
JavaScript
67.1%
TypeScript
29.4%
HTML
1.5%
CSS
1.1%
C++
0.6%
Other
0.2%