-
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.
[compiler] Errors in earlier functions dont stop subsequent compilation
Errors in an earlier component/hook shouldn't stop later components from compiling. ghstack-source-id: a82cca9855adab77493e0a140d2a142788375d0d Pull Request resolved: #30844
- Loading branch information
1 parent
c741d2d
commit f0c8f95
Showing
4 changed files
with
79 additions
and
22 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
50 changes: 50 additions & 0 deletions
50
.../src/__tests__/fixtures/compiler/multiple-components-first-is-invalid.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,50 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @panicThreshold(none) | ||
import {useHook} from 'shared-runtime'; | ||
|
||
function InvalidComponent(props) { | ||
if (props.cond) { | ||
useHook(); | ||
} | ||
return <div>Hello World!</div>; | ||
} | ||
|
||
function ValidComponent(props) { | ||
return <div>{props.greeting}</div>; | ||
} | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; // @panicThreshold(none) | ||
import { useHook } from "shared-runtime"; | ||
|
||
function InvalidComponent(props) { | ||
if (props.cond) { | ||
useHook(); | ||
} | ||
return <div>Hello World!</div>; | ||
} | ||
|
||
function ValidComponent(props) { | ||
const $ = _c(2); | ||
let t0; | ||
if ($[0] !== props.greeting) { | ||
t0 = <div>{props.greeting}</div>; | ||
$[0] = props.greeting; | ||
$[1] = t0; | ||
} else { | ||
t0 = $[1]; | ||
} | ||
return t0; | ||
} | ||
|
||
``` | ||
### Eval output | ||
(kind: exception) Fixture not implemented |
13 changes: 13 additions & 0 deletions
13
...in-react-compiler/src/__tests__/fixtures/compiler/multiple-components-first-is-invalid.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,13 @@ | ||
// @panicThreshold(none) | ||
import {useHook} from 'shared-runtime'; | ||
|
||
function InvalidComponent(props) { | ||
if (props.cond) { | ||
useHook(); | ||
} | ||
return <div>Hello World!</div>; | ||
} | ||
|
||
function ValidComponent(props) { | ||
return <div>{props.greeting}</div>; | ||
} |