@samitouri / QOS-React-1 / commits / 88186db690

[hir] Make hoisting a TODO bailout

Sathya Gunasekaran committed Sep 13, 2023 at 17:58 UTC 88186db6904869fadca719739ae6d51c2634efe8
5 files changed +13 -10
compiler/packages/babel-plugin-react-forget/src/SSA/EnterSSA.ts
+9 -6
@@ -97,12 +97,14 @@ class SSABuilder {
97
98 definePlace(oldPlace: Place): Place {
99 const oldId = oldPlace.identifier;
100 - CompilerError.invariant(!this.#unknown.has(oldId), {
101 - reason: `EnterSSA: Expected identifier to be defined before being used`,
102 - description: `Identifier ${printIdentifier(oldId)} is undefined`,
103 - loc: oldPlace.loc,
104 - suggestions: null,
105 - });
100 + if (this.#unknown.has(oldId)) {
101 + CompilerError.todo({
102 + reason: `EnterSSA: Expected identifier to be defined before being used`,
103 + description: `Identifier ${printIdentifier(oldId)} is undefined`,
104 + loc: oldPlace.loc,
105 + suggestions: null,
106 + });
107 + }
108
109 // Do not redefine context references.
110 if (this.#context.has(oldId)) {
@@ -244,6 +246,7 @@ function enterSSAImpl(
246 loc: null,
247 suggestions: null,
248 });
249 +
250 visitedBlocks.add(block);
251
252 builder.startBlock(block);
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.hoisted-function-declaration.expect.md
+1 -1
@@ -17,7 +17,7 @@ function component(a) {
17 ## Error
18
19 ```
20 -[ReactForget] Invariant: EnterSSA: Expected identifier to be defined before being used. Identifier x$5 is undefined
20 +[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier x$5 is undefined
21 ```
22
23
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-captured-arg-separately.expect.md
+1 -1
@@ -19,7 +19,7 @@ function component(a) {
19 ## Error
20
21 ```
22 -[ReactForget] Invariant: EnterSSA: Expected identifier to be defined before being used. Identifier x$1 is undefined (7:7)
22 +[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier x$1 is undefined (7:7)
23 ```
24
25
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-hoisting-simple-function-expression.expect.md
+1 -1
@@ -25,7 +25,7 @@ export const FIXTURE_ENTRYPOINT = {
25 ## Error
26
27 ```
28 -[ReactForget] Invariant: EnterSSA: Expected identifier to be defined before being used. Identifier bar$0 is undefined (5:7)
28 +[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier bar$0 is undefined (5:7)
29 ```
30
31
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-hoisting-simple-let-const-declaration.expect.md
+1 -1
@@ -23,7 +23,7 @@ export const FIXTURE_ENTRYPOINT = {
23 ## Error
24
25 ```
26 -[ReactForget] Invariant: EnterSSA: Expected identifier to be defined before being used. Identifier bar$0 is undefined (5:5)
26 +[ReactForget] Todo: EnterSSA: Expected identifier to be defined before being used. Identifier bar$0 is undefined (5:5)
27 ```
28
29
\ No newline at end of file