@samitouri / QOS-React-1 / commits / 480c11bdb1

[hoisting] Make hoisting related errors consolidatable

Noticed from our paste that we weren't correctly rolling up hoisting related errors due to specific information being in the error title, so this PR moves them into description instead.

Lauren Tan committed Nov 13, 2023 at 16:54 UTC 480c11bdb199794160cab0ede3a7b696e47edb98
10 files changed +14 -15
compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts
+5 -6
@@ -27,6 +27,7 @@ import {
27 } from "../HIR/HIR";
28 import { FunctionSignature } from "../HIR/ObjectShape";
29 import {
30 + printIdentifier,
31 printMixedHIR,
32 printPlace,
33 printSourceLocation,
@@ -231,10 +232,8 @@ class InferenceState {
232 kind(place: Place): ValueKind {
233 const values = this.#variables.get(place.identifier.id);
234 CompilerError.invariant(values != null, {
234 - reason: `Expected value kind to be initialized at '${printSourceLocation(
235 - place.loc
236 - )}'`,
237 - description: null,
235 + reason: `[hoisting] Expected value kind to be initialized`,
236 + description: `${printPlace(place)}`,
237 loc: place.loc,
238 suggestions: null,
239 });
@@ -256,8 +255,8 @@ class InferenceState {
255 alias(place: Place, value: Place): void {
256 const values = this.#variables.get(value.identifier.id);
257 CompilerError.invariant(values != null, {
259 - reason: `Expected value for identifier \`${value.identifier.id}\` to be initialized.`,
260 - description: null,
258 + reason: `[hoisting] Expected value for identifier to be initialized`,
259 + description: `${printIdentifier(value.identifier)}`,
260 loc: value.loc,
261 suggestions: null,
262 });
compiler/packages/babel-plugin-react-forget/src/SSA/EnterSSA.ts
+1 -1
@@ -99,7 +99,7 @@ class SSABuilder {
99 const oldId = oldPlace.identifier;
100 if (this.#unknown.has(oldId)) {
101 CompilerError.throwTodo({
102 - reason: `EnterSSA: Expected identifier to be defined before being used`,
102 + reason: `[hoisting] EnterSSA: Expected identifier to be defined before being used`,
103 description: `Identifier ${printIdentifier(oldId)} is undefined`,
104 loc: oldPlace.loc,
105 suggestions: null,
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bug-hoisting-nested-block-statements.expect.md
+1 -1
@@ -24,7 +24,7 @@ export const FIXTURE_ENTRYPOINT = {
24 ## Error
25
26 ```
27 -[ReactForget] Invariant: Expected value kind to be initialized at '8:6:8:7' (8:8)
27 +[ReactForget] Invariant: [hoisting] Expected value kind to be initialized. read x_0$10 (8:8)
28 ```
29
30
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bug-hoisting.expect.md
+1 -1
@@ -20,7 +20,7 @@ function Component(props) {
20 ## Error
21
22 ```
23 -[ReactForget] Invariant: Expected value kind to be initialized at '8:25:8:33' (8:8)
23 +[ReactForget] Invariant: [hoisting] Expected value kind to be initialized. read pathname_0$12 (8:8)
24 ```
25
26
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.bug-hoisting2.expect.md
+1 -1
@@ -18,7 +18,7 @@ function Component() {
18 ## Error
19
20 ```
21 -[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier handler$1 is undefined (3:7)
21 +[ReactForget] Todo: [hoisting] EnterSSA: Expected identifier to be defined before being used. Identifier handler$1 is undefined (3:7)
22 ```
23
24
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.hoisted-function-declaration.expect.md
+1 -1
@@ -17,7 +17,7 @@ function component(a) {
17 ## Error
18
19 ```
20 -[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier x$5 is undefined
20 +[ReactForget] Todo: [hoisting] EnterSSA: Expected identifier to be defined before being used. Identifier x$5 is undefined
21 ```
22
23
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.hoisting-simple-function-declaration.expect.md
+1 -1
@@ -24,7 +24,7 @@ export const FIXTURE_ENTRYPOINT = {
24 ## Error
25
26 ```
27 -[ReactForget] Invariant: Expected value for identifier `5` to be initialized. (5:5)
27 +[ReactForget] Invariant: [hoisting] Expected value for identifier to be initialized. baz$5 (5:5)
28 ```
29
30
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-captured-arg-separately.expect.md
+1 -1
@@ -19,7 +19,7 @@ function component(a) {
19 ## Error
20
21 ```
22 -[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier x$1 is undefined (7:7)
22 +[ReactForget] Todo: [hoisting] EnterSSA: Expected identifier to be defined before being used. Identifier x$1 is undefined (7:7)
23 ```
24
25
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.repro-uninitialized-value-kind-with-function-expression-params.expect.md
+1 -1
@@ -18,7 +18,7 @@ function Component(props) {
18 ## Error
19
20 ```
21 -[ReactForget] Invariant: Expected value kind to be initialized at '8:9:8:10' (8:8)
21 +[ReactForget] Invariant: [hoisting] Expected value kind to be initialized. read x_0$21 (8:8)
22 ```
23
24
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-recursive-references-inner-functions.expect.md
+1 -1
@@ -25,7 +25,7 @@ export const FIXTURE_ENTRYPONT = {
25 ## Error
26
27 ```
28 -[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier factorial$3 is undefined (2:8)
28 +[ReactForget] Todo: [hoisting] EnterSSA: Expected identifier to be defined before being used. Identifier factorial$3 is undefined (2:8)
29 ```
30
31
\ No newline at end of file