From 89ea2d5f7c13195e6963ba8fc5119a910b4b546c Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 30 Mar 2023 15:50:07 -0400 Subject: [PATCH] [be] Fix missing break and update no-fallthrough eslint rule - Fixes a missing break in InferTypes - I disabled no-fallthrough previously because it would erroneously report that certain cases with non-builtin throws (eg `invariant`) would fall through. This brings the rule back but allows disabling it with a `// break omitted` comment, since it's still helpful in catching some actual missing breaks. --- .../forget/src/TypeInference/InferTypes.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/compiler/forget/src/TypeInference/InferTypes.ts b/compiler/forget/src/TypeInference/InferTypes.ts index 561fb983e4..8fafb2c60a 100644 --- a/compiler/forget/src/TypeInference/InferTypes.ts +++ b/compiler/forget/src/TypeInference/InferTypes.ts @@ -12,6 +12,7 @@ import { } from "../HIR/HIR"; import { BuiltInArrayId, BuiltInObjectId } from "../HIR/ObjectShape"; import { eachInstructionLValue, eachInstructionOperand } from "../HIR/visitors"; +import { assertExhaustive } from "../Utils/utils"; function isPrimitiveBinaryOp(op: t.BinaryExpression["operator"]): boolean { switch (op) { @@ -182,7 +183,29 @@ function* generateInstructionTypes( }); yield equation(left, returnType); + break; } + + case "DeclareLocal": + case "Destructure": + case "NewExpression": + case "TypeCastExpression": + case "JsxExpression": + case "JsxFragment": + case "RegExpLiteral": + case "PropertyStore": + case "PropertyDelete": + case "ComputedStore": + case "ComputedLoad": + case "ComputedDelete": + case "FunctionExpression": + case "TaggedTemplateExpression": + case "TemplateLiteral": + case "Await": + case "UnsupportedNode": + break; + default: + assertExhaustive(value, `Unhandled instruction value kind: ${value}`); } }