mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Update (base update)
[ghstack-poisoned]
This commit is contained in:
+11
-9
@@ -195,12 +195,12 @@ class PropertyPathRegistry {
|
||||
}
|
||||
|
||||
function addNonNullPropertyPath(
|
||||
node: PropertyPathNode,
|
||||
source: Identifier,
|
||||
sourceNode: PropertyPathNode,
|
||||
instrId: InstructionId,
|
||||
knownImmutableIdentifiers: Set<IdentifierId>,
|
||||
result: Set<PropertyPathNode>,
|
||||
): void {
|
||||
const object = node.fullPath.identifier;
|
||||
/**
|
||||
* Since this runs *after* buildReactiveScopeTerminals, identifier mutable ranges
|
||||
* are not valid with respect to current instruction id numbering.
|
||||
@@ -212,14 +212,14 @@ function addNonNullPropertyPath(
|
||||
* See comment at top of function for why we track known immutable identifiers.
|
||||
*/
|
||||
const isMutableAtInstr =
|
||||
object.mutableRange.end > object.mutableRange.start + 1 &&
|
||||
object.scope != null &&
|
||||
inRange({id: instrId}, object.scope.range);
|
||||
source.mutableRange.end > source.mutableRange.start + 1 &&
|
||||
source.scope != null &&
|
||||
inRange({id: instrId}, source.scope.range);
|
||||
if (
|
||||
!isMutableAtInstr ||
|
||||
knownImmutableIdentifiers.has(node.fullPath.identifier.id)
|
||||
knownImmutableIdentifiers.has(sourceNode.fullPath.identifier.id)
|
||||
) {
|
||||
result.add(node);
|
||||
result.add(sourceNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,9 +282,9 @@ function collectNonNullsInBlocks(
|
||||
identifier: instr.value.object.identifier,
|
||||
path: [],
|
||||
};
|
||||
const propertyNode = registry.getOrCreateProperty(source);
|
||||
addNonNullPropertyPath(
|
||||
propertyNode,
|
||||
instr.value.object.identifier,
|
||||
registry.getOrCreateProperty(source),
|
||||
instr.id,
|
||||
knownImmutableIdentifiers,
|
||||
assumedNonNullObjects,
|
||||
@@ -297,6 +297,7 @@ function collectNonNullsInBlocks(
|
||||
const sourceNode = temporaries.get(source);
|
||||
if (sourceNode != null) {
|
||||
addNonNullPropertyPath(
|
||||
instr.value.value.identifier,
|
||||
registry.getOrCreateProperty(sourceNode),
|
||||
instr.id,
|
||||
knownImmutableIdentifiers,
|
||||
@@ -311,6 +312,7 @@ function collectNonNullsInBlocks(
|
||||
const sourceNode = temporaries.get(source);
|
||||
if (sourceNode != null) {
|
||||
addNonNullPropertyPath(
|
||||
instr.value.object.identifier,
|
||||
registry.getOrCreateProperty(sourceNode),
|
||||
instr.id,
|
||||
knownImmutableIdentifiers,
|
||||
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
import {identity} from 'shared-runtime';
|
||||
|
||||
function useFoo(maybeNullObject: {value: {inner: number}} | null) {
|
||||
const y = [];
|
||||
try {
|
||||
y.push(identity(maybeNullObject.value.inner));
|
||||
} catch {
|
||||
y.push('null');
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: useFoo,
|
||||
params: [null],
|
||||
sequentialRenders: [null, {value: 2}, {value: 3}, null],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { identity } from "shared-runtime";
|
||||
|
||||
function useFoo(maybeNullObject) {
|
||||
const $ = _c(2);
|
||||
let y;
|
||||
if ($[0] !== maybeNullObject.value.inner) {
|
||||
y = [];
|
||||
try {
|
||||
y.push(identity(maybeNullObject.value.inner));
|
||||
} catch {
|
||||
y.push("null");
|
||||
}
|
||||
$[0] = maybeNullObject.value.inner;
|
||||
$[1] = y;
|
||||
} else {
|
||||
y = $[1];
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: useFoo,
|
||||
params: [null],
|
||||
sequentialRenders: [null, { value: 2 }, { value: 3 }, null],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
import {identity} from 'shared-runtime';
|
||||
|
||||
function useFoo(maybeNullObject: {value: {inner: number}} | null) {
|
||||
const y = [];
|
||||
try {
|
||||
y.push(identity(maybeNullObject.value.inner));
|
||||
} catch {
|
||||
y.push('null');
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: useFoo,
|
||||
params: [null],
|
||||
sequentialRenders: [null, {value: 2}, {value: 3}, null],
|
||||
};
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enablePropagateDepsInHIR
|
||||
import {identity} from 'shared-runtime';
|
||||
|
||||
function useFoo(maybeNullObject: {value: {inner: number}} | null) {
|
||||
const y = [];
|
||||
try {
|
||||
y.push(identity(maybeNullObject.value.inner));
|
||||
} catch {
|
||||
y.push('null');
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: useFoo,
|
||||
params: [null],
|
||||
sequentialRenders: [null, {value: 2}, {value: 3}, null],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
|
||||
import { identity } from "shared-runtime";
|
||||
|
||||
function useFoo(maybeNullObject) {
|
||||
const $ = _c(4);
|
||||
let y;
|
||||
if ($[0] !== maybeNullObject) {
|
||||
y = [];
|
||||
try {
|
||||
let t0;
|
||||
if ($[2] !== maybeNullObject.value.inner) {
|
||||
t0 = identity(maybeNullObject.value.inner);
|
||||
$[2] = maybeNullObject.value.inner;
|
||||
$[3] = t0;
|
||||
} else {
|
||||
t0 = $[3];
|
||||
}
|
||||
y.push(t0);
|
||||
} catch {
|
||||
y.push("null");
|
||||
}
|
||||
$[0] = maybeNullObject;
|
||||
$[1] = y;
|
||||
} else {
|
||||
y = $[1];
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: useFoo,
|
||||
params: [null],
|
||||
sequentialRenders: [null, { value: 2 }, { value: 3 }, null],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: ok) ["null"]
|
||||
[null]
|
||||
[null]
|
||||
["null"]
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// @enablePropagateDepsInHIR
|
||||
import {identity} from 'shared-runtime';
|
||||
|
||||
function useFoo(maybeNullObject: {value: {inner: number}} | null) {
|
||||
const y = [];
|
||||
try {
|
||||
y.push(identity(maybeNullObject.value.inner));
|
||||
} catch {
|
||||
y.push('null');
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: useFoo,
|
||||
params: [null],
|
||||
sequentialRenders: [null, {value: 2}, {value: 3}, null],
|
||||
};
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enablePropagateDepsInHIR
|
||||
const {throwInput} = require('shared-runtime');
|
||||
|
||||
function Component(props) {
|
||||
let x;
|
||||
try {
|
||||
const y = [];
|
||||
y.push(props.y);
|
||||
throwInput(y);
|
||||
} catch (e) {
|
||||
e.push(props.e);
|
||||
x = e;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{y: 'foo', e: 'bar'}],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
|
||||
const { throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
const $ = _c(2);
|
||||
let x;
|
||||
if ($[0] !== props) {
|
||||
try {
|
||||
const y = [];
|
||||
y.push(props.y);
|
||||
throwInput(y);
|
||||
} catch (t0) {
|
||||
const e = t0;
|
||||
e.push(props.e);
|
||||
x = e;
|
||||
}
|
||||
$[0] = props;
|
||||
$[1] = x;
|
||||
} else {
|
||||
x = $[1];
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ y: "foo", e: "bar" }],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: ok) ["foo","bar"]
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// @enablePropagateDepsInHIR
|
||||
const {throwInput} = require('shared-runtime');
|
||||
|
||||
function Component(props) {
|
||||
let x;
|
||||
try {
|
||||
const y = [];
|
||||
y.push(props.y);
|
||||
throwInput(y);
|
||||
} catch (e) {
|
||||
e.push(props.e);
|
||||
x = e;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{y: 'foo', e: 'bar'}],
|
||||
};
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
// @enablePropagateDepsInHIR
|
||||
const {throwInput} = require('shared-runtime');
|
||||
|
||||
function Component(props) {
|
||||
try {
|
||||
const y = [];
|
||||
y.push(props.y);
|
||||
throwInput(y);
|
||||
} catch (e) {
|
||||
e.push(props.e);
|
||||
return e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{y: 'foo', e: 'bar'}],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR
|
||||
const { throwInput } = require("shared-runtime");
|
||||
|
||||
function Component(props) {
|
||||
const $ = _c(2);
|
||||
let t0;
|
||||
if ($[0] !== props) {
|
||||
t0 = Symbol.for("react.early_return_sentinel");
|
||||
bb0: {
|
||||
try {
|
||||
const y = [];
|
||||
y.push(props.y);
|
||||
throwInput(y);
|
||||
} catch (t1) {
|
||||
const e = t1;
|
||||
e.push(props.e);
|
||||
t0 = e;
|
||||
break bb0;
|
||||
}
|
||||
}
|
||||
$[0] = props;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
if (t0 !== Symbol.for("react.early_return_sentinel")) {
|
||||
return t0;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ y: "foo", e: "bar" }],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: ok) ["foo","bar"]
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// @enablePropagateDepsInHIR
|
||||
const {throwInput} = require('shared-runtime');
|
||||
|
||||
function Component(props) {
|
||||
try {
|
||||
const y = [];
|
||||
y.push(props.y);
|
||||
throwInput(y);
|
||||
} catch (e) {
|
||||
e.push(props.e);
|
||||
return e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{y: 'foo', e: 'bar'}],
|
||||
};
|
||||
@@ -478,7 +478,6 @@ const skipFilter = new Set([
|
||||
'fbt/bug-fbt-plural-multiple-function-calls',
|
||||
'fbt/bug-fbt-plural-multiple-mixed-call-tag',
|
||||
'bug-invalid-hoisting-functionexpr',
|
||||
'bug-try-catch-maybe-null-dependency',
|
||||
'reduce-reactive-deps/bug-merge-uncond-optional-chain-and-cond',
|
||||
'original-reactive-scopes-fork/bug-nonmutating-capture-in-unsplittable-memo-block',
|
||||
'original-reactive-scopes-fork/bug-hoisted-declaration-with-scope',
|
||||
|
||||
Reference in New Issue
Block a user