-
Notifications
You must be signed in to change notification settings - Fork 47.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ghstack-source-id: 02f4698bd98705a855deb0d4bc30b9829afdddc0 Pull Request resolved: #30674
- Loading branch information
Showing
19 changed files
with
381 additions
and
51 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
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
File renamed without changes.
31 changes: 0 additions & 31 deletions
31
.../src/__tests__/fixtures/compiler/error.mutate-captured-arg-separately.expect.md
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...in-react-compiler/src/__tests__/fixtures/compiler/error.mutate-captured-arg-separately.js
This file was deleted.
Oops, something went wrong.
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
62 changes: 62 additions & 0 deletions
62
...ler/src/__tests__/fixtures/compiler/hoisting-nested-let-declaration-2.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,62 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
function hoisting(cond) { | ||
let items = []; | ||
if (cond) { | ||
let foo = () => { | ||
items.push(bar()); | ||
}; | ||
let bar = () => true; | ||
foo(); | ||
} | ||
return items; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: hoisting, | ||
params: [true], | ||
isComponent: false, | ||
}; | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; | ||
function hoisting(cond) { | ||
const $ = _c(2); | ||
let items; | ||
if ($[0] !== cond) { | ||
items = []; | ||
if (cond) { | ||
const foo = () => { | ||
items.push(bar()); | ||
}; | ||
|
||
let bar = _temp; | ||
foo(); | ||
} | ||
$[0] = cond; | ||
$[1] = items; | ||
} else { | ||
items = $[1]; | ||
} | ||
return items; | ||
} | ||
function _temp() { | ||
return true; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: hoisting, | ||
params: [true], | ||
isComponent: false, | ||
}; | ||
|
||
``` | ||
### Eval output | ||
(kind: ok) [true] |
17 changes: 17 additions & 0 deletions
17
...lugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-nested-let-declaration-2.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,17 @@ | ||
function hoisting(cond) { | ||
let items = []; | ||
if (cond) { | ||
let foo = () => { | ||
items.push(bar()); | ||
}; | ||
let bar = () => true; | ||
foo(); | ||
} | ||
return items; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: hoisting, | ||
params: [true], | ||
isComponent: false, | ||
}; |
65 changes: 65 additions & 0 deletions
65
...piler/src/__tests__/fixtures/compiler/hoisting-nested-let-declaration.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,65 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
function hoisting() { | ||
let qux = () => { | ||
let result; | ||
{ | ||
result = foo(); | ||
} | ||
return result; | ||
}; | ||
let foo = () => { | ||
return bar + baz; | ||
}; | ||
let bar = 3; | ||
const baz = 2; | ||
return qux(); // OK: called outside of TDZ | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: hoisting, | ||
params: [], | ||
isComponent: false, | ||
}; | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; | ||
function hoisting() { | ||
const $ = _c(1); | ||
let t0; | ||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) { | ||
const qux = () => { | ||
let result; | ||
|
||
result = foo(); | ||
return result; | ||
}; | ||
|
||
let foo = () => bar + baz; | ||
|
||
let bar = 3; | ||
const baz = 2; | ||
t0 = qux(); | ||
$[0] = t0; | ||
} else { | ||
t0 = $[0]; | ||
} | ||
return t0; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: hoisting, | ||
params: [], | ||
isComponent: false, | ||
}; | ||
|
||
``` | ||
### Eval output | ||
(kind: ok) 5 |
Oops, something went wrong.