-
Notifications
You must be signed in to change notification settings - Fork 47.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler] Reordering of logical expressions
ghstack-source-id: 0f92be69d258ddfdb10e39dcbc80819557be2441 Pull Request resolved: #30678
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 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
43 changes: 43 additions & 0 deletions
43
...n-react-compiler/src/__tests__/fixtures/compiler/logical-reorder.flow.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,43 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
//@flow | ||
|
||
const foo = undefined; | ||
|
||
component C( | ||
...{ | ||
scope = foo ?? null, | ||
}: any | ||
) { | ||
return scope; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: C, | ||
params: [{scope: undefined}], | ||
}; | ||
|
||
``` | ||
## Code | ||
```javascript | ||
const foo = undefined; | ||
|
||
function C(t0) { | ||
const { scope: t1 } = t0; | ||
const scope = t1 === undefined ? (foo ?? null) : t1; | ||
return scope; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: C, | ||
params: [{ scope: undefined }], | ||
}; | ||
|
||
``` | ||
### Eval output | ||
(kind: ok) null |
16 changes: 16 additions & 0 deletions
16
...kages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/logical-reorder.flow.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,16 @@ | ||
//@flow | ||
|
||
const foo = undefined; | ||
|
||
component C( | ||
...{ | ||
scope = foo ?? null, | ||
}: any | ||
) { | ||
return scope; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: C, | ||
params: [{scope: undefined}], | ||
}; |