[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.
This commit is contained in:
Lauren Tan
2023-11-13 16:54:54 -05:00
parent 800b874ed1
commit 480c11bdb1
10 changed files with 14 additions and 15 deletions
@@ -27,6 +27,7 @@ import {
} from "../HIR/HIR";
import { FunctionSignature } from "../HIR/ObjectShape";
import {
printIdentifier,
printMixedHIR,
printPlace,
printSourceLocation,
@@ -231,10 +232,8 @@ class InferenceState {
kind(place: Place): ValueKind {
const values = this.#variables.get(place.identifier.id);
CompilerError.invariant(values != null, {
reason: `Expected value kind to be initialized at '${printSourceLocation(
place.loc
)}'`,
description: null,
reason: `[hoisting] Expected value kind to be initialized`,
description: `${printPlace(place)}`,
loc: place.loc,
suggestions: null,
});
@@ -256,8 +255,8 @@ class InferenceState {
alias(place: Place, value: Place): void {
const values = this.#variables.get(value.identifier.id);
CompilerError.invariant(values != null, {
reason: `Expected value for identifier \`${value.identifier.id}\` to be initialized.`,
description: null,
reason: `[hoisting] Expected value for identifier to be initialized`,
description: `${printIdentifier(value.identifier)}`,
loc: value.loc,
suggestions: null,
});
@@ -99,7 +99,7 @@ class SSABuilder {
const oldId = oldPlace.identifier;
if (this.#unknown.has(oldId)) {
CompilerError.throwTodo({
reason: `EnterSSA: Expected identifier to be defined before being used`,
reason: `[hoisting] EnterSSA: Expected identifier to be defined before being used`,
description: `Identifier ${printIdentifier(oldId)} is undefined`,
loc: oldPlace.loc,
suggestions: null,
@@ -24,7 +24,7 @@ export const FIXTURE_ENTRYPOINT = {
## Error
```
[ReactForget] Invariant: Expected value kind to be initialized at '8:6:8:7' (8:8)
[ReactForget] Invariant: [hoisting] Expected value kind to be initialized. read x_0$10 (8:8)
```
@@ -20,7 +20,7 @@ function Component(props) {
## Error
```
[ReactForget] Invariant: Expected value kind to be initialized at '8:25:8:33' (8:8)
[ReactForget] Invariant: [hoisting] Expected value kind to be initialized. read pathname_0$12 (8:8)
```
@@ -18,7 +18,7 @@ function Component() {
## Error
```
[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier handler$1 is undefined (3:7)
[ReactForget] Todo: [hoisting] EnterSSA: Expected identifier to be defined before being used. Identifier handler$1 is undefined (3:7)
```
@@ -17,7 +17,7 @@ function component(a) {
## Error
```
[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier x$5 is undefined
[ReactForget] Todo: [hoisting] EnterSSA: Expected identifier to be defined before being used. Identifier x$5 is undefined
```
@@ -24,7 +24,7 @@ export const FIXTURE_ENTRYPOINT = {
## Error
```
[ReactForget] Invariant: Expected value for identifier `5` to be initialized. (5:5)
[ReactForget] Invariant: [hoisting] Expected value for identifier to be initialized. baz$5 (5:5)
```
@@ -19,7 +19,7 @@ function component(a) {
## Error
```
[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier x$1 is undefined (7:7)
[ReactForget] Todo: [hoisting] EnterSSA: Expected identifier to be defined before being used. Identifier x$1 is undefined (7:7)
```
@@ -18,7 +18,7 @@ function Component(props) {
## Error
```
[ReactForget] Invariant: Expected value kind to be initialized at '8:9:8:10' (8:8)
[ReactForget] Invariant: [hoisting] Expected value kind to be initialized. read x_0$21 (8:8)
```
@@ -25,7 +25,7 @@ export const FIXTURE_ENTRYPONT = {
## Error
```
[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier factorial$3 is undefined (2:8)
[ReactForget] Todo: [hoisting] EnterSSA: Expected identifier to be defined before being used. Identifier factorial$3 is undefined (2:8)
```