-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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: 6e04a5bb2e2045303cbddad6d6d4bd38d5f7990b Pull Request resolved: #30844
- Loading branch information
1 parent
61739a8
commit 071dd00
Showing
7 changed files
with
125 additions
and
14 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
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>; | ||
} |
39 changes: 39 additions & 0 deletions
39
...__/fixtures/compiler/unclosed-eslint-suppression-skips-all-components.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,39 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @panicThreshold(none) | ||
|
||
// unclosed disable rule should affect all components | ||
/* eslint-disable react-hooks/rules-of-hooks */ | ||
|
||
function ValidComponent1(props) { | ||
return <div>Hello World!</div>; | ||
} | ||
|
||
function ValidComponent2(props) { | ||
return <div>{props.greeting}</div>; | ||
} | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
// @panicThreshold(none) | ||
|
||
// unclosed disable rule should affect all components | ||
/* eslint-disable react-hooks/rules-of-hooks */ | ||
|
||
function ValidComponent1(props) { | ||
return <div>Hello World!</div>; | ||
} | ||
|
||
function ValidComponent2(props) { | ||
return <div>{props.greeting}</div>; | ||
} | ||
|
||
``` | ||
### Eval output | ||
(kind: exception) Fixture not implemented |
12 changes: 12 additions & 0 deletions
12
...piler/src/__tests__/fixtures/compiler/unclosed-eslint-suppression-skips-all-components.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,12 @@ | ||
// @panicThreshold(none) | ||
|
||
// unclosed disable rule should affect all components | ||
/* eslint-disable react-hooks/rules-of-hooks */ | ||
|
||
function ValidComponent1(props) { | ||
return <div>Hello World!</div>; | ||
} | ||
|
||
function ValidComponent2(props) { | ||
return <div>{props.greeting}</div>; | ||
} |