mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Repro for unsupported recursive function expressions
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component() {
|
||||
function callback(x) {
|
||||
if (x == 0) {
|
||||
return null;
|
||||
}
|
||||
return callback(x - 1);
|
||||
}
|
||||
return callback(10);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
4 | return null;
|
||||
5 | }
|
||||
> 6 | return callback(x - 1);
|
||||
| ^^^^^^^^^^^^^^^ [ReactForget] Todo: Unsupported declaration type for hoisting. variable "callback" declared with FunctionDeclaration (6:6)
|
||||
7 | }
|
||||
8 | return callback(10);
|
||||
9 | }
|
||||
```
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
function Component() {
|
||||
function callback(x) {
|
||||
if (x == 0) {
|
||||
return null;
|
||||
}
|
||||
return callback(x - 1);
|
||||
}
|
||||
return callback(10);
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function foo() {
|
||||
(() => foo())();
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function foo() {
|
||||
foo();
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
function foo() {
|
||||
(() => foo())();
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function foo(x) {
|
||||
if (x <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return x + foo(x - 1) + (() => foo(x - 2))();
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: foo,
|
||||
params: [10],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function foo(x) {
|
||||
if (x <= 0) {
|
||||
return 0;
|
||||
}
|
||||
let t0;
|
||||
t0 = foo(x - 2);
|
||||
return x + foo(x - 1) + t0;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: foo,
|
||||
params: [10],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: ok) 364
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function foo(x) {
|
||||
if (x <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return x + foo(x - 1) + (() => foo(x - 2))();
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: foo,
|
||||
params: [10],
|
||||
};
|
||||
Reference in New Issue
Block a user