diff --git a/compiler/forget/src/HIR/Dominator.ts b/compiler/forget/src/HIR/Dominator.ts index b53fe41d7e..e4a50c73ad 100644 --- a/compiler/forget/src/HIR/Dominator.ts +++ b/compiler/forget/src/HIR/Dominator.ts @@ -113,10 +113,9 @@ class Dominator { */ get(id: T): T | null { const dominator = this.#nodes.get(id); - invariant( - dominator !== undefined, - `Called on invalid node identifier '${id}'` - ); + if (dominator === undefined) { + return null; + } return dominator === id ? null : dominator; } @@ -173,7 +172,7 @@ function computeReverseGraph(fn: HIRFunction): Graph { preds: new Set(eachTerminalSuccessor(block.terminal)), succs: new Set(block.preds), }; - if (block.terminal.kind === "return" || block.terminal.kind === "throw") { + if (block.terminal.kind === "return") { node.preds.add(exitId); exit.succs.add(id); }