Reclassify existing errors
Most of these errors were incorrectly using InvalidInput as a catchall for rejecting code. I went through each one and manually updated them to be more accurate
Lauren Tan committed
Jun 27, 2023 at 14:01 UTC
c3d678985734c3657a551b88e03bbfca36228ae8
1 file changed
+13
-15
compiler/forget/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts
+13
-15
@@ -1005,7 +1005,7 @@ function lowerExpression(
1005
} else {
1006
builder.errors.push({
1007
reason: `(BuildHIR::lowerExpression) Expected Identifier, got ${key.type} key in ObjectExpression`,
1008
- severity: ErrorSeverity.InvalidInput,
1008
+ severity: ErrorSeverity.Todo,
1009
loc: propertyPath.node.loc ?? null,
1010
});
1011
continue;
@@ -1089,7 +1089,7 @@ function lowerExpression(
1089
if (!calleePath.isExpression()) {
1090
builder.errors.push({
1091
reason: `(BuildHIR::lowerExpression) Expected Expression, got ${calleePath.type} in NewExpression (v8 intrinsics not supported): ${calleePath.type}`,
1092
- severity: ErrorSeverity.InvalidInput,
1092
+ severity: ErrorSeverity.Todo,
1093
loc: calleePath.node.loc ?? null,
1094
});
1095
return { kind: "UnsupportedNode", node: exprNode, loc: exprLoc };
@@ -1114,7 +1114,7 @@ function lowerExpression(
1114
if (!calleePath.isExpression()) {
1115
builder.errors.push({
1116
reason: `(BuildHIR::lowerExpression) Expected Expression, got ${calleePath.type} in CallExpression (v8 intrinsics not supported)`,
1117
- severity: ErrorSeverity.InvalidInput,
1117
+ severity: ErrorSeverity.Todo,
1118
loc: calleePath.node.loc ?? null,
1119
});
1120
return { kind: "UnsupportedNode", node: exprNode, loc: exprLoc };
@@ -1147,7 +1147,7 @@ function lowerExpression(
1147
if (!leftPath.isExpression()) {
1148
builder.errors.push({
1149
reason: `(BuildHIR::lowerExpression) Expected Expression, got ${leftPath.type} lval in BinaryExpression`,
1150
- severity: ErrorSeverity.InvalidInput,
1150
+ severity: ErrorSeverity.Todo,
1151
loc: leftPath.node.loc ?? null,
1152
});
1153
return { kind: "UnsupportedNode", node: exprNode, loc: exprLoc };
@@ -1461,7 +1461,7 @@ function lowerExpression(
1461
default: {
1462
builder.errors.push({
1463
reason: `(BuildHIR::lowerExpression) Expected Identifier or MemberExpression, got ${expr.type} lval in AssignmentExpression`,
1464
- severity: ErrorSeverity.InvalidInput,
1464
+ severity: ErrorSeverity.Todo,
1465
loc: expr.node.loc ?? null,
1466
});
1467
return { kind: "UnsupportedNode", node: exprNode, loc: exprLoc };
@@ -2185,7 +2185,7 @@ function lowerMemberExpression(
2185
if (!propertyNode.isExpression()) {
2186
builder.errors.push({
2187
reason: `(BuildHIR::lowerMemberExpression) Expected Expression, got ${propertyNode.type} property`,
2188
- severity: ErrorSeverity.InvalidInput,
2188
+ severity: ErrorSeverity.Todo,
2189
loc: propertyNode.node.loc ?? null,
2190
});
2191
return {
@@ -2325,13 +2325,11 @@ function lowerJsxElement(
2325
});
2326
return place;
2327
} else {
2328
- if (!(t.isJSXFragment(exprNode) || t.isJSXSpreadChild(exprNode))) {
2329
- builder.errors.push({
2330
- reason: `(BuildHIR::lowerJsxElement) Expected refinement to work, got: ${exprPath.type}`,
2331
- severity: ErrorSeverity.InvalidInput,
2332
- loc: exprPath.node.loc ?? null,
2333
- });
2334
- }
2328
+ builder.errors.push({
2329
+ reason: `(BuildHIR::lowerJsxElement) Unhandled JsxElement, got: ${exprPath.type}`,
2330
+ severity: ErrorSeverity.Todo,
2331
+ loc: exprPath.node.loc ?? null,
2332
+ });
2333
const place = lowerValueToTemporary(builder, {
2334
kind: "UnsupportedNode",
2335
node: exprNode,
@@ -2592,7 +2590,7 @@ function lowerAssignment(
2590
builder.errors.push({
2591
reason:
2592
"(BuildHIR::lowerAssignment) Expected private name to appear as a non-computed property",
2595
- severity: ErrorSeverity.InvalidInput,
2593
+ severity: ErrorSeverity.Todo,
2594
loc: property.node.loc ?? null,
2595
});
2596
return { kind: "UnsupportedNode", node: lvalueNode, loc };
@@ -2740,7 +2738,7 @@ function lowerAssignment(
2738
if (!element.isLVal()) {
2739
builder.errors.push({
2740
reason: `(BuildHIR::lowerAssignment) Expected object property value to be an LVal, got: ${element.type}`,
2743
- severity: ErrorSeverity.InvalidInput,
2741
+ severity: ErrorSeverity.Todo,
2742
loc: element.node.loc ?? null,
2743
});
2744
continue;