From 325987d744ed992a7147dba78a89d8ea80e0e85d Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 12 Jan 2023 19:35:19 -0500 Subject: [PATCH] Delete old CompilerError module This was a carryover from the old architecture; we can remove it now to get rid of the indirection. --- compiler/forget/src/HIR/BuildHIR.ts | 2 +- compiler/forget/src/HIR/HIR.ts | 2 +- compiler/forget/src/HIR/HIRBuilder.ts | 2 +- .../forget/src/HIR/MergeConsecutiveBlocks.ts | 2 +- .../src/Inference/InferReferenceEffects.ts | 4 ++-- .../AlignReactiveScopesToBlockScopes.ts | 2 +- .../MergeOverlappingReactiveScopes.ts | 2 +- .../ReactiveScopes/PrintReactiveFunction.ts | 2 +- .../src/ReactiveScopes/RenameVariables.ts | 2 +- compiler/forget/src/SSA/EnterSSA.ts | 2 +- compiler/forget/src/Utils/CompilerError.ts | 20 ------------------- compiler/forget/src/Utils/DisjointSet.ts | 2 +- 12 files changed, 12 insertions(+), 32 deletions(-) delete mode 100644 compiler/forget/src/Utils/CompilerError.ts diff --git a/compiler/forget/src/HIR/BuildHIR.ts b/compiler/forget/src/HIR/BuildHIR.ts index ff633bc2fa..273ad8e140 100644 --- a/compiler/forget/src/HIR/BuildHIR.ts +++ b/compiler/forget/src/HIR/BuildHIR.ts @@ -7,7 +7,7 @@ import { NodePath, Scope } from "@babel/traverse"; import * as t from "@babel/types"; -import { invariant } from "../Utils/CompilerError"; +import invariant from "invariant"; import todo, { todoInvariant } from "../Utils/todo"; import { assertExhaustive } from "../Utils/utils"; import { diff --git a/compiler/forget/src/HIR/HIR.ts b/compiler/forget/src/HIR/HIR.ts index a4d8a4c9d3..8ca75dd57e 100644 --- a/compiler/forget/src/HIR/HIR.ts +++ b/compiler/forget/src/HIR/HIR.ts @@ -6,7 +6,7 @@ */ import * as t from "@babel/types"; -import { invariant } from "../Utils/CompilerError"; +import invariant from "invariant"; // ******************************************************************************************* // ******************************************************************************************* diff --git a/compiler/forget/src/HIR/HIRBuilder.ts b/compiler/forget/src/HIR/HIRBuilder.ts index 8d19448259..42186e8d42 100644 --- a/compiler/forget/src/HIR/HIRBuilder.ts +++ b/compiler/forget/src/HIR/HIRBuilder.ts @@ -6,7 +6,7 @@ */ import * as t from "@babel/types"; -import { invariant } from "../Utils/CompilerError"; +import invariant from "invariant"; import { logHIR } from "../Utils/logger"; import { assertExhaustive } from "../Utils/utils"; import { diff --git a/compiler/forget/src/HIR/MergeConsecutiveBlocks.ts b/compiler/forget/src/HIR/MergeConsecutiveBlocks.ts index 5f83abd1ae..caadb23f39 100644 --- a/compiler/forget/src/HIR/MergeConsecutiveBlocks.ts +++ b/compiler/forget/src/HIR/MergeConsecutiveBlocks.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import { invariant } from "../Utils/CompilerError"; +import invariant from "invariant"; import { BlockId, Effect, diff --git a/compiler/forget/src/Inference/InferReferenceEffects.ts b/compiler/forget/src/Inference/InferReferenceEffects.ts index 1a6da443fd..e6c90eb73b 100644 --- a/compiler/forget/src/Inference/InferReferenceEffects.ts +++ b/compiler/forget/src/Inference/InferReferenceEffects.ts @@ -5,8 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import { invariant } from "../Utils/CompilerError"; -import { assertExhaustive } from "../Utils/utils"; +import invariant from "invariant"; import { BasicBlock, BlockId, @@ -29,6 +28,7 @@ import { eachTerminalOperand, eachTerminalSuccessor, } from "../HIR/visitors"; +import { assertExhaustive } from "../Utils/utils"; /** * For every usage of a value in the given function, infers the effect or action diff --git a/compiler/forget/src/ReactiveScopes/AlignReactiveScopesToBlockScopes.ts b/compiler/forget/src/ReactiveScopes/AlignReactiveScopesToBlockScopes.ts index 5acca0032b..11908ef69f 100644 --- a/compiler/forget/src/ReactiveScopes/AlignReactiveScopesToBlockScopes.ts +++ b/compiler/forget/src/ReactiveScopes/AlignReactiveScopesToBlockScopes.ts @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +import invariant from "invariant"; import { InstructionId, makeInstructionId, @@ -14,7 +15,6 @@ import { ReactiveValueBlock, ScopeId, } from "../HIR/HIR"; -import { invariant } from "../Utils/CompilerError"; import { getInstructionScope, getPlaceScope } from "./BuildReactiveBlocks"; import { eachTerminalBlock, eachTerminalOperand } from "./visitors"; diff --git a/compiler/forget/src/ReactiveScopes/MergeOverlappingReactiveScopes.ts b/compiler/forget/src/ReactiveScopes/MergeOverlappingReactiveScopes.ts index 1687d5ca22..f087600dd2 100644 --- a/compiler/forget/src/ReactiveScopes/MergeOverlappingReactiveScopes.ts +++ b/compiler/forget/src/ReactiveScopes/MergeOverlappingReactiveScopes.ts @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +import invariant from "invariant"; import { InstructionId, InstructionValue, @@ -17,7 +18,6 @@ import { ScopeId, } from "../HIR"; import { eachInstructionValueOperand } from "../HIR/visitors"; -import { invariant } from "../Utils/CompilerError"; import DisjointSet from "../Utils/DisjointSet"; import { retainWhere } from "../Utils/utils"; import { getPlaceScope } from "./BuildReactiveBlocks"; diff --git a/compiler/forget/src/ReactiveScopes/PrintReactiveFunction.ts b/compiler/forget/src/ReactiveScopes/PrintReactiveFunction.ts index a25d6cafa8..9eda5275f2 100644 --- a/compiler/forget/src/ReactiveScopes/PrintReactiveFunction.ts +++ b/compiler/forget/src/ReactiveScopes/PrintReactiveFunction.ts @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +import invariant from "invariant"; import { ReactiveFunction, ReactiveScopeBlock, @@ -19,7 +20,6 @@ import { printInstructionValue, printPlace, } from "../HIR/PrintHIR"; -import { invariant } from "../Utils/CompilerError"; import { assertExhaustive } from "../Utils/utils"; export function printReactiveFunction(fn: ReactiveFunction): string { diff --git a/compiler/forget/src/ReactiveScopes/RenameVariables.ts b/compiler/forget/src/ReactiveScopes/RenameVariables.ts index 0f8a99175a..1049f850f8 100644 --- a/compiler/forget/src/ReactiveScopes/RenameVariables.ts +++ b/compiler/forget/src/ReactiveScopes/RenameVariables.ts @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +import invariant from "invariant"; import { Identifier, IdentifierId, @@ -14,7 +15,6 @@ import { ReactiveValueBlock, } from "../HIR/HIR"; import { eachInstructionValueOperand } from "../HIR/visitors"; -import { invariant } from "../Utils/CompilerError"; import { assertExhaustive } from "../Utils/utils"; /** diff --git a/compiler/forget/src/SSA/EnterSSA.ts b/compiler/forget/src/SSA/EnterSSA.ts index 09b3e6f8ca..3081a9f6c2 100644 --- a/compiler/forget/src/SSA/EnterSSA.ts +++ b/compiler/forget/src/SSA/EnterSSA.ts @@ -1,3 +1,4 @@ +import invariant from "invariant"; import { BasicBlock, BlockId, @@ -17,7 +18,6 @@ import { mapInstructionOperands, mapTerminalOperands, } from "../HIR/visitors"; -import { invariant } from "../Utils/CompilerError"; type IncompletePhi = { oldId: Identifier; diff --git a/compiler/forget/src/Utils/CompilerError.ts b/compiler/forget/src/Utils/CompilerError.ts deleted file mode 100644 index 54ba8b33b9..0000000000 --- a/compiler/forget/src/Utils/CompilerError.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import invariant from "invariant"; - -// Record a bailout if there is an invariant violation and a recently created compiler context. -// Otherwise, just throws a regular invariant. -function compilerInvariant( - condition: unknown, - format: string, - ...args: any[] -): asserts condition { - return invariant(condition, format, ...args); -} - -export { compilerInvariant as invariant }; diff --git a/compiler/forget/src/Utils/DisjointSet.ts b/compiler/forget/src/Utils/DisjointSet.ts index c6c71e86a7..1074623959 100644 --- a/compiler/forget/src/Utils/DisjointSet.ts +++ b/compiler/forget/src/Utils/DisjointSet.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import { invariant } from "./CompilerError"; +import invariant from "invariant"; /** * Represents items which form disjoint sets.