-
Notifications
You must be signed in to change notification settings - Fork 47.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler] Handle optional where innermost property access is non-opt…
…ional Handles an additional case as part of testing combinations of the same path being accessed in different places with different segments as optional/unconditional. [ghstack-poisoned]
- Loading branch information
1 parent
d29206b
commit 34f5c6e
Showing
3 changed files
with
136 additions
and
3 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
46 changes: 46 additions & 0 deletions
46
...compiler/optional-member-expression-inverted-optionals-parallel-paths.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,46 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @validatePreserveExistingMemoizationGuarantees @enableOptionalDependencies | ||
import {ValidateMemoization} from 'shared-runtime'; | ||
function Component(props) { | ||
const data = useMemo(() => { | ||
const x = []; | ||
x.push(props?.a.b?.c.d?.e); | ||
x.push(props.a?.b.c?.d.e); | ||
return x; | ||
}, [props.a.b.c.d.e]); | ||
return <ValidateMemoization inputs={[props.a.b.c.d.e]} output={x} />; | ||
} | ||
|
||
``` | ||
## Code | ||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; // @validatePreserveExistingMemoizationGuarantees @enableOptionalDependencies | ||
import { ValidateMemoization } from "shared-runtime"; | ||
function Component(props) { | ||
const $ = _c(2); | ||
let t0; | ||
|
||
const x$0 = []; | ||
x$0.push(props?.a.b?.c.d?.e); | ||
x$0.push(props.a?.b.c?.d.e); | ||
t0 = x$0; | ||
let t1; | ||
if ($[0] !== props.a.b.c.d.e) { | ||
t1 = <ValidateMemoization inputs={[props.a.b.c.d.e]} output={x} />; | ||
$[0] = props.a.b.c.d.e; | ||
$[1] = t1; | ||
} else { | ||
t1 = $[1]; | ||
} | ||
return t1; | ||
} | ||
|
||
``` | ||
### Eval output | ||
(kind: exception) Fixture not implemented |
11 changes: 11 additions & 0 deletions
11
...tests__/fixtures/compiler/optional-member-expression-inverted-optionals-parallel-paths.js
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,11 @@ | ||
// @validatePreserveExistingMemoizationGuarantees @enableOptionalDependencies | ||
import {ValidateMemoization} from 'shared-runtime'; | ||
function Component(props) { | ||
const data = useMemo(() => { | ||
const x = []; | ||
x.push(props?.a.b?.c.d?.e); | ||
x.push(props.a?.b.c?.d.e); | ||
return x; | ||
}, [props.a.b.c.d.e]); | ||
return <ValidateMemoization inputs={[props.a.b.c.d.e]} output={x} />; | ||
} |