[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.
Lauren Tan committed
Mar 30, 2023 at 15:50 UTC
89ea2d5f7c13195e6963ba8fc5119a910b4b546c
1 file changed
+23
compiler/forget/src/TypeInference/InferTypes.ts
+23
@@ -12,6 +12,7 @@ import {
12
} from "../HIR/HIR";
13
import { BuiltInArrayId, BuiltInObjectId } from "../HIR/ObjectShape";
14
import { eachInstructionLValue, eachInstructionOperand } from "../HIR/visitors";
15
+import { assertExhaustive } from "../Utils/utils";
16
17
function isPrimitiveBinaryOp(op: t.BinaryExpression["operator"]): boolean {
18
switch (op) {
@@ -182,7 +183,29 @@ function* generateInstructionTypes(
183
});
184
185
yield equation(left, returnType);
186
+ break;
187
}
188
+
189
+ case "DeclareLocal":
190
+ case "Destructure":
191
+ case "NewExpression":
192
+ case "TypeCastExpression":
193
+ case "JsxExpression":
194
+ case "JsxFragment":
195
+ case "RegExpLiteral":
196
+ case "PropertyStore":
197
+ case "PropertyDelete":
198
+ case "ComputedStore":
199
+ case "ComputedLoad":
200
+ case "ComputedDelete":
201
+ case "FunctionExpression":
202
+ case "TaggedTemplateExpression":
203
+ case "TemplateLiteral":
204
+ case "Await":
205
+ case "UnsupportedNode":
206
+ break;
207
+ default:
208
+ assertExhaustive(value, `Unhandled instruction value kind: ${value}`);
209
}
210
}
211