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:
Joe Savona committed 2024-03-08 13:59:20 -08:00
1 parent fe91bcefd2
commit 7605e89a50
2 files changed
+32

No files matched your search

@@ -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() {}
```
@@ -0,0 +1,6 @@
function Component() {
return <Foo />;
// This is unreachable from a control-flow perspective, but it gets hoisted
function Foo() {}
}