-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler] Implement support for non-declaration for initializers
ghstack-source-id: 894914ab8c31b8b308cac05b07a0cc351419346e Pull Request resolved: #31712
- Loading branch information
Showing
6 changed files
with
101 additions
and
53 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
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
...babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-inits.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 | ||
function Foo() { | ||
let i = 0; | ||
for (42; i < 1; i += 1) {} | ||
for (bar(); i < 1; i += 1) {} | ||
for (; i < 1; i += 1) {} | ||
for (i = 0; i < 1; i += 1) {} | ||
} | ||
|
||
function bar() {} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [], | ||
}; | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
function Foo() { | ||
let i = 0; | ||
for (42; i < 1; i = i + 1, i) {} | ||
for (bar(); i < 1; i = i + 1, i) {} | ||
for (undefined; i < 1; i = i + 1, i) {} | ||
for (i = 0; i < 1; i = i + 1, i) {} | ||
} | ||
|
||
function bar() {} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [], | ||
}; | ||
|
||
``` | ||
### Eval output | ||
(kind: ok) |
14 changes: 14 additions & 0 deletions
14
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-inits.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,14 @@ | ||
function Foo() { | ||
let i = 0; | ||
for (42; i < 1; i += 1) {} | ||
for (bar(); i < 1; i += 1) {} | ||
for (; i < 1; i += 1) {} | ||
for (i = 0; i < 1; i += 1) {} | ||
} | ||
|
||
function bar() {} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [], | ||
}; |