Files
react/compiler
Mofei Zhang 1fdbcfe162 [rhir] Add dependencies produced by active (incomplete) scopes
--- 

> If this operand is used in a scope, has a dynamic value, and was defined 
before this scope, then its a dependency of the scope. 

> (from current comments in PropagateScopeDependencies::visitDependency) 

A reactive scope can take a dependency from a definition produced by an 
incomplete parent scope. Our tests previously did not cover this, since most 
object types aliased together and remained mutable throughout a ReactiveScope. 

e.g. our tests did not have 

``` 

scope @0 (deps=...,  declarations=[x, y]) { 

x = {}; 

// define a reactive, immutable value that is not aliased to become mutable 

const immutableVal = ...; 

scope @1 (deps=immutableVal, declarations=[y]) { 

y = read(immutableVal) 

} 

mutateX(x, ...); 

} 

``` 

We should not add a dependency if it is produced in exactly the same scope as 
the one it is used. It is safe (and correct) to depend on values produced by a 
parent scope. 

--- 

Note that we still should check for whether a defining scope is active to 
determine whether it should be added as a output of that scope 
([src](https://github.com/facebook/react-forget/blob/b608ab20d57229b528deeffa19f1ee08a4bad37a/forget/src/ReactiveScopes/PropagateScopeDependencies.ts#L469-L478)). 

Access of an identifier produced by a parent scope (i.e. adding a variable 
defined by a scope's parent as its own dependency) does not require adding that 
identifier to the parent's `declarations`, since that identifier is already 
valid to access via identifier binding rules.
2023-02-28 16:36:01 -05:00
..
2024-03-25 10:39:47 +00:00
2024-03-25 10:39:47 +00:00
2022-11-15 13:24:14 -05:00
2024-03-25 10:39:47 +00:00
2024-03-25 10:39:47 +00:00
2024-03-25 10:39:47 +00:00