-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ghstack-poisoned]
- Loading branch information
Showing
8 changed files
with
312 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...compiler/propagate-scope-deps-hir-fork/infer-component-props-non-null.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @enablePropagateDepsInHIR:enabled_with_optimizations | ||
import {identity, Stringify} from 'shared-runtime'; | ||
|
||
function Foo(props) { | ||
/** | ||
* props.value should be inferred as the dependency of this scope | ||
* since we know that props is safe to read from (i.e. non-null) | ||
* as it is arg[0] of a component function | ||
*/ | ||
const arr = []; | ||
if (cond) { | ||
arr.push(identity(props.value)); | ||
} | ||
return <Stringify arr={arr} />; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [{value: 2}], | ||
}; | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; // @enablePropagateDepsInHIR:enabled_with_optimizations | ||
import { identity, Stringify } from "shared-runtime"; | ||
|
||
function Foo(props) { | ||
const $ = _c(2); | ||
let t0; | ||
if ($[0] !== props.value) { | ||
const arr = []; | ||
if (cond) { | ||
arr.push(identity(props.value)); | ||
} | ||
|
||
t0 = <Stringify arr={arr} />; | ||
$[0] = props.value; | ||
$[1] = t0; | ||
} else { | ||
t0 = $[1]; | ||
} | ||
return t0; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [{ value: 2 }], | ||
}; | ||
|
||
``` | ||
### Eval output | ||
(kind: exception) cond is not defined |
20 changes: 20 additions & 0 deletions
20
...ests__/fixtures/compiler/propagate-scope-deps-hir-fork/infer-component-props-non-null.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @enablePropagateDepsInHIR:enabled_with_optimizations | ||
import {identity, Stringify} from 'shared-runtime'; | ||
|
||
function Foo(props) { | ||
/** | ||
* props.value should be inferred as the dependency of this scope | ||
* since we know that props is safe to read from (i.e. non-null) | ||
* as it is arg[0] of a component function | ||
*/ | ||
const arr = []; | ||
if (cond) { | ||
arr.push(identity(props.value)); | ||
} | ||
return <Stringify arr={arr} />; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [{value: 2}], | ||
}; |
Oops, something went wrong.