diff --git a/compiler/forget/src/HIR/BuildHIR.ts b/compiler/forget/src/HIR/BuildHIR.ts
index 968e19ac31..35bcf71115 100644
--- a/compiler/forget/src/HIR/BuildHIR.ts
+++ b/compiler/forget/src/HIR/BuildHIR.ts
@@ -1351,7 +1351,7 @@ function lowerExpression(
for (const p of expr.get("params")) {
if (!p.isIdentifier()) {
builder.pushError({
- reason: "Handle non identifier params",
+ reason: `Support non identifier params: ${p.type}`,
severity: ErrorSeverity.Todo,
nodePath: p,
});
@@ -1563,7 +1563,25 @@ function lowerJsxElement(
return lowerExpressionToPlace(builder, exprPath);
} else if (exprPath.isJSXExpressionContainer()) {
const expression = exprPath.get("expression");
- todoInvariant(expression.isExpression(), "handle empty expressions");
+ if (!expression.isExpression()) {
+ builder.pushError({
+ reason: "Handle empty expressions",
+ severity: ErrorSeverity.Todo,
+ nodePath: expression,
+ });
+ const place: Place = buildTemporaryPlace(builder, exprLoc);
+ builder.push({
+ id: makeInstructionId(0),
+ value: {
+ kind: "UnsupportedNode",
+ node: exprNode,
+ loc: exprLoc,
+ },
+ loc: exprLoc,
+ lvalue: { place: { ...place }, kind: InstructionKind.Const },
+ });
+ return { ...place };
+ }
return lowerExpressionToPlace(builder, expression);
} else if (exprPath.isJSXText()) {
const place: Place = buildTemporaryPlace(builder, exprLoc);
@@ -1579,10 +1597,13 @@ function lowerJsxElement(
});
return place;
} else {
- invariant(
- t.isJSXFragment(exprNode) || t.isJSXSpreadChild(exprNode),
- "Expected refinement to work"
- );
+ if (!(t.isJSXFragment(exprNode) || t.isJSXSpreadChild(exprNode))) {
+ builder.pushError({
+ reason: "Expected refinement to work",
+ severity: ErrorSeverity.InvalidInput,
+ nodePath: exprPath,
+ });
+ }
const place: Place = buildTemporaryPlace(builder, exprLoc);
builder.push({
id: makeInstructionId(0),
diff --git a/compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.expect.md b/compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.expect.md
index 0f834380cd..99065e34ef 100644
--- a/compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.expect.md
+++ b/compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.expect.md
@@ -25,6 +25,7 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
;
;
;
+ ;
;
const j = function bar([quz, qux], ...args) {};
@@ -149,7 +150,7 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
| ^^^^^^^^^
22 | ;
23 | ;
- 24 | ;
+ 24 | ;
[ReactForget] TodoError: Handle non-identifier jsx attribute names
20 |
@@ -157,86 +158,95 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
> 22 | ;
| ^^^^^^^^^^
23 | ;
- 24 | ;
- 25 |
+ 24 | ;
+ 25 | ;
-[ReactForget] TodoError: Handle non-identifier tags
+[ReactForget] TodoError: Handle empty expressions
22 | ;
23 | ;
-> 24 | ;
+> 24 | ;
+ | ^^^^^^^^^^^^
+ 25 | ;
+ 26 |
+ 27 | const j = function bar([quz, qux], ...args) {};
+
+[ReactForget] TodoError: Handle non-identifier tags
+ 23 | ;
+ 24 | ;
+> 25 | ;
| ^^^^^^^^^^^^^^^^^^^
- 25 |
- 26 | const j = function bar([quz, qux], ...args) {};
- 27 |
+ 26 |
+ 27 | const j = function bar([quz, qux], ...args) {};
+ 28 |
-[ReactForget] TodoError: Handle non identifier params
- 24 | ;
- 25 |
-> 26 | const j = function bar([quz, qux], ...args) {};
+[ReactForget] TodoError: Support non-identifier params: ArrayPattern
+ 25 | ;
+ 26 |
+> 27 | const j = function bar([quz, qux], ...args) {};
| ^^^^^^^^^^
- 27 |
- 28 | for (; i < 3; i += 1) {
- 29 | x.push(i);
+ 28 |
+ 29 | for (; i < 3; i += 1) {
+ 30 | x.push(i);
-[ReactForget] TodoError: Handle non identifier params
- 24 | ;
- 25 |
-> 26 | const j = function bar([quz, qux], ...args) {};
+[ReactForget] TodoError: Support non-identifier params: RestElement
+ 25 | ;
+ 26 |
+> 27 | const j = function bar([quz, qux], ...args) {};
| ^^^^^^^
- 27 |
- 28 | for (; i < 3; i += 1) {
- 29 | x.push(i);
+ 28 |
+ 29 | for (; i < 3; i += 1) {
+ 30 | x.push(i);
[ReactForget] TodoError: Support non-variable initialization in for
- 26 | const j = function bar([quz, qux], ...args) {};
- 27 |
-> 28 | for (; i < 3; i += 1) {
+ 27 | const j = function bar([quz, qux], ...args) {};
+ 28 |
+> 29 | for (; i < 3; i += 1) {
| ^
- 29 | x.push(i);
- 30 | }
- 31 | for (; i < 3; ) {}
+ 30 | x.push(i);
+ 31 | }
+ 32 | for (; i < 3; ) {}
[ReactForget] TodoError: Support non-variable initialization in for
- 29 | x.push(i);
- 30 | }
-> 31 | for (; i < 3; ) {}
+ 30 | x.push(i);
+ 31 | }
+> 32 | for (; i < 3; ) {}
| ^^^^^^^^^^^^^^^^^^
- 32 | for (;;) {}
- 33 | }
- 34 |
+ 33 | for (;;) {}
+ 34 | }
+ 35 |
[ReactForget] TodoError: Handle empty for updater
- 29 | x.push(i);
- 30 | }
-> 31 | for (; i < 3; ) {}
+ 30 | x.push(i);
+ 31 | }
+> 32 | for (; i < 3; ) {}
| ^^^^^^^^^^^^^^^^^^
- 32 | for (;;) {}
- 33 | }
- 34 |
+ 33 | for (;;) {}
+ 34 | }
+ 35 |
[ReactForget] TodoError: Support non-variable initialization in for
- 30 | }
- 31 | for (; i < 3; ) {}
-> 32 | for (;;) {}
+ 31 | }
+ 32 | for (; i < 3; ) {}
+> 33 | for (;;) {}
| ^^^^^^^^^^^
- 33 | }
- 34 |
+ 34 | }
+ 35 |
[ReactForget] TodoError: Handle empty for updater
- 30 | }
- 31 | for (; i < 3; ) {}
-> 32 | for (;;) {}
+ 31 | }
+ 32 | for (; i < 3; ) {}
+> 33 | for (;;) {}
| ^^^^^^^^^^^
- 33 | }
- 34 |
+ 34 | }
+ 35 |
[ReactForget] TodoError: ForStatement without test
- 30 | }
- 31 | for (; i < 3; ) {}
-> 32 | for (;;) {}
+ 31 | }
+ 32 | for (; i < 3; ) {}
+> 33 | for (;;) {}
| ^^^^^^^^^^^
- 33 | }
- 34 |
+ 34 | }
+ 35 |
```
\ No newline at end of file
diff --git a/compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.js b/compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.js
index 6e76f4e91b..66c4f8787a 100644
--- a/compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.js
+++ b/compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.js
@@ -21,6 +21,7 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
;
;
;
+ ;
;
const j = function bar([quz, qux], ...args) {};