Address code review
Joe Savona committed
Apr 26, 2023 at 11:27 UTC
d4b8df54410eaae8adb81e94f32698ef9386b610
1 file changed
+8
-5
compiler/forget/src/ReactiveScopes/PromoteUsedTemporaries.ts
+8
-5
@@ -5,7 +5,8 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import invariant from "invariant";
8
+import { CompilerError } from "../CompilerError";
9
+import { GeneratedSource } from "../HIR";
10
import {
11
Identifier,
12
IdentifierId,
@@ -73,10 +74,12 @@ export function promoteUsedTemporaries(fn: ReactiveFunction): void {
74
}
75
76
function promoteTemporary(identifier: Identifier, state: VisitorState): void {
76
- invariant(
77
- identifier.name === null,
78
- "Expected to be called only for temporaries"
79
- );
77
+ if (identifier.name !== null) {
78
+ CompilerError.invariant(
79
+ "promoteTemporary: Expected to be called only for temporary variables",
80
+ GeneratedSource
81
+ );
82
+ }
83
if (state.tags.has(identifier.id)) {
84
identifier.name = `T${state.nextId++}`;
85
} else {