[hir] Fix typescript warnings
Sathya Gunasekaran committed
Jan 19, 2023 at 12:07 UTC
a5b245b17d789a2ee8ff9789cca82e394449a3d9
3 files changed
+7
-4
compiler/forget/src/HIR/BuildHIR.ts
+4
-2
@@ -13,6 +13,8 @@ import { Err, Ok, Result } from "../lib/Result";
13
import todo, { todoInvariant } from "../Utils/todo";
14
import { assertExhaustive } from "../Utils/utils";
15
import {
16
+ BlockId,
17
+ Case,
18
Effect,
19
GeneratedSource,
20
GotoVariant,
@@ -159,7 +161,7 @@ function lowerStatement(
161
};
162
});
163
// Block for the alternate (if the test is not truthy)
162
- let alternateBlock = null;
164
+ let alternateBlock: BlockId;
165
const alternate = stmt.get("alternate");
166
if (alternate.hasNode()) {
167
alternateBlock = builder.enter("block", (blockId) => {
@@ -564,7 +566,7 @@ function lowerStatement(
566
* Iterate through cases in reverse order, so that previous blocks can fallthrough
567
* to successors
568
*/
567
- const cases = [];
569
+ const cases: Case[] = [];
570
let hasDefault = false;
571
for (let ii = stmt.get("cases").length - 1; ii >= 0; ii--) {
572
const case_: NodePath<t.SwitchCase> = stmt.get("cases")[ii];
compiler/forget/src/HIR/HIR.ts
+2
-1
@@ -224,6 +224,7 @@ export type ValueTerminal = IfTerminal | GotoTerminal;
224
// A terminal that couldn't be lowered correctly.
225
export type ErrorTerminal = { kind: "error"; id: InstructionId };
226
export type ThrowTerminal = { kind: "throw"; value: Place; id: InstructionId };
227
+export type Case = { test: Place | null; block: BlockId };
228
229
export type ReturnTerminal = {
230
kind: "return";
@@ -256,7 +257,7 @@ export type IfTerminal = {
257
export type SwitchTerminal = {
258
kind: "switch";
259
test: Place;
259
- cases: Array<{ test: Place | null; block: BlockId }>;
260
+ cases: Case[];
261
fallthrough: BlockId | null;
262
id: InstructionId;
263
};
compiler/forget/src/SSA/EnterSSA.ts
+1
-1
@@ -161,7 +161,7 @@ class SSABuilder {
161
}
162
163
print() {
164
- const text = [];
164
+ const text: string[] = [];
165
for (const [block, state] of this.#states) {
166
text.push(`bb${block.id}:`);
167
for (const [oldId, newId] of state.defs) {