mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Repro for "unreachable" hoisted function
For T175282529. We already detect hoisted functions and have a specific todo for them, but in this case the function is in unreachable code that gets pruned during BuildHIR. The later check for hoisted functions doesn't find it.
This commit is contained in:
1 parent
fe91bcefd2
commit
7605e89a50
2 files changed
+32
No files matched your search
+26
@@ -0,0 +1,26 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component() {
|
||||
return <Foo />;
|
||||
|
||||
// This is unreachable from a control-flow perspective, but it gets hoisted
|
||||
function Foo() {}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
1 | function Component() {
|
||||
> 2 | return <Foo />;
|
||||
| ^^^ [ReactForget] Invariant: [hoisting] Expected value for identifier to be initialized. Foo$0 (2:2)
|
||||
3 |
|
||||
4 | // This is unreachable from a control-flow perspective, but it gets hoisted
|
||||
5 | function Foo() {}
|
||||
```
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
function Component() {
|
||||
return <Foo />;
|
||||
|
||||
// This is unreachable from a control-flow perspective, but it gets hoisted
|
||||
function Foo() {}
|
||||
}
|
||||
Reference in new issue
Block a user