Distinguish error fixtures for invalid code
Renames some error fixtures for clarity, "error.invalid-*" are fixtures that are expected to fail for invalid input, where other "error.*" fixtures are basically todos. While i was here i clarified the error messages for invalid useMemo callbacks, and changes the error severity from Invariant to InvalidInput.
Joe Savona committed
Jun 4, 2023 at 11:41 UTC
084edadaa1fe173d2c89e022c570e0b1bcdc405e
11 files changed
+6
-6
compiler/forget/src/Inference/InlineUseMemo.ts
+4
-4
@@ -100,15 +100,15 @@ export function inlineUseMemo(fn: HIRFunction): void {
100
}
101
102
if (body.loweredFunc.params.length > 0) {
103
- CompilerError.invariant(
104
- "Did not expect any arguments to useMemo callback",
103
+ CompilerError.invalidInput(
104
+ "useMemo callbacks may not accept any arguments",
105
body.loc
106
);
107
}
108
109
if (body.loweredFunc.async || body.loweredFunc.generator) {
110
- CompilerError.invariant(
111
- "Did not expect useMemo callback to be async or a generator",
110
+ CompilerError.invalidInput(
111
+ "useMemo callbacks may not be async or generator functions",
112
body.loc
113
);
114
}
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-aliased-freeze.expect.md
renamed
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-aliased-freeze.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-freeze.expect.md
renamed
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-mutate-after-freeze.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-sketchy-code-use-forget.expect.md
renamed
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-sketchy-code-use-forget.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-useMemo-async-callback.expect.md
renamed
+1
-1
@@ -15,7 +15,7 @@ function component(a, b) {
15
## Error
16
17
```
18
-[ReactForget] Invariant: Did not expect useMemo callback to be async or a generator (2:4)
18
+[ReactForget] InvalidInput: useMemo callbacks may not be async or generator functions (2:4)
19
```
20
21
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-useMemo-async-callback.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/error.invalid-useMemo-callback-args.expect.md
renamed
+1
-1
@@ -13,7 +13,7 @@ function component(a, b) {
13
## Error
14
15
```
16
-[ReactForget] Invariant: Did not expect any arguments to useMemo callback (2:2)
16
+[ReactForget] InvalidInput: useMemo callbacks may not accept any arguments (2:2)
17
```
18
19
\ No newline at end of file