Record more errors in BuildHIR::lowerStatement
Captures other kinds of statements that we're lowering to OtherStatements as TODO errors
Lauren Tan committed
Jan 18, 2023 at 10:58 UTC
23a044e406c4004e3fc8a2cd2a269068079a9b5c
3 files changed
+30
compiler/forget/src/HIR/BuildHIR.ts
+6
@@ -753,6 +753,12 @@ function lowerStatement(
753
case "TSNamespaceExportDeclaration":
754
case "TSTypeAliasDeclaration":
755
case "WithStatement": {
756
+ builder.pushError({
757
+ reason: `Unhandled statement type: ${stmtPath.type}`,
758
+ severity: ErrorSeverity.Todo,
759
+ source: stmtPath.toString(),
760
+ loc: null,
761
+ });
762
builder.push({
763
id: makeInstructionId(0),
764
lvalue: {
compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.expect.md
+19
@@ -6,6 +6,11 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
6
let i = 0;
7
var x = [];
8
9
+ class Bar {}
10
+
11
+ with (true) {
12
+ }
13
+
14
for (; i < 3; i += 1) {
15
x.push(i);
16
}
@@ -27,6 +32,8 @@ function foo([a, b], {
32
}, f = "f", ...args) {
33
let i = 0;
34
var x = [];
35
+ class Bar {}
36
+ with (true) {}
37
for (; i < 3; i += 1) {
38
x.push(i);
39
}
@@ -42,6 +49,8 @@ function foo([a, b], {
49
}, f = "f", ...args) {
50
let i = 0;
51
var x = [];
52
+ class Bar {}
53
+ with (true) {}
54
for (; i < 3; i += 1) {
55
x.push(i);
56
}
@@ -57,6 +66,8 @@ function foo([a, b], {
66
}, f = "f", ...args) {
67
let i = 0;
68
var x = [];
69
+ class Bar {}
70
+ with (true) {}
71
for (; i < 3; i += 1) {
72
x.push(i);
73
}
@@ -72,6 +83,8 @@ function foo([a, b], {
83
}, f = "f", ...args) {
84
let i = 0;
85
var x = [];
86
+ class Bar {}
87
+ with (true) {}
88
for (; i < 3; i += 1) {
89
x.push(i);
90
}
@@ -82,6 +95,12 @@ function foo([a, b], {
95
Forget Error: [TODO] `var` declarations are not supported, use let or const on lines 3:3
96
var x = [];
97
98
+Forget Error: [TODO] Unhandled statement type: ClassDeclaration
99
+class Bar {}
100
+
101
+Forget Error: [TODO] Unhandled statement type: WithStatement
102
+with (true) {}
103
+
104
Forget Error: [TODO] Support non-variable initialization in for
105
for (; i < 3; i += 1) {
106
x.push(i);
compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.js
+5
@@ -2,6 +2,11 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
2
let i = 0;
3
var x = [];
4
5
+ class Bar {}
6
+
7
+ with (true) {
8
+ }
9
+
10
for (; i < 3; i += 1) {
11
x.push(i);
12
}