From 58100e3d60124cfc41268c27f8b68ff00cc00685 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Fri, 14 Oct 2022 12:10:53 -0400 Subject: [PATCH] Use CompilerError invariant The CompilerError module's `invariant` is wired up to our bailout system so in compiler passes should be preferred to the raw `invariant` module. We should probably add an internal eslint rule to suggest using CompilerError if the file is in one of the compiler pass directories. --- compiler/forget/src/BackEnd/LIRGen.ts | 2 +- compiler/forget/src/BackEnd/SanityCheck.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/forget/src/BackEnd/LIRGen.ts b/compiler/forget/src/BackEnd/LIRGen.ts index 08501a3124..bffa690b9f 100644 --- a/compiler/forget/src/BackEnd/LIRGen.ts +++ b/compiler/forget/src/BackEnd/LIRGen.ts @@ -7,9 +7,9 @@ import { NodePath } from "@babel/traverse"; import * as t from "@babel/types"; -import invariant from "invariant"; import { setEmpty, setEq, setIntersect, setSubset } from "../Common/utils"; import type { CompilerContext } from "../CompilerContext"; +import { invariant } from "../CompilerError"; import * as IR from "../IR"; import * as LIR from "../LIR"; import { PassKind, PassName } from "../Pass"; diff --git a/compiler/forget/src/BackEnd/SanityCheck.ts b/compiler/forget/src/BackEnd/SanityCheck.ts index c07ef52451..cc2651234e 100644 --- a/compiler/forget/src/BackEnd/SanityCheck.ts +++ b/compiler/forget/src/BackEnd/SanityCheck.ts @@ -7,14 +7,14 @@ import type { NodePath } from "@babel/traverse"; import * as t from "@babel/types"; -import type { CompilerContext } from "../CompilerContext"; -import { OutputKind } from "../CompilerOutputs"; -import * as LIR from "../LIR"; -import * as IR from "../IR"; -import { PassKind, PassName } from "../Pass"; import { assertExhaustive } from "../Common/utils"; -import invariant from "invariant"; +import type { CompilerContext } from "../CompilerContext"; +import { invariant } from "../CompilerError"; +import { OutputKind } from "../CompilerOutputs"; +import * as IR from "../IR"; +import * as LIR from "../LIR"; import { isReactiveBlock, isRenderBlock } from "../LIR"; +import { PassKind, PassName } from "../Pass"; /** * An optional debug step when the output {@link OutputKind.IR} is enabled.