Skip to content

Commit ae87fc7

Browse files
committed
fix bug where boolean can be expected in equality checks before source 3
1 parent 927bb5b commit ae87fc7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

server/src/rules/binaryExpression.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ export const binaryExpressionRule = new class extends Rule<BinaryExpression> {
3939
// undefined is an identifier so we have to check this first
4040
if (child.left.type === NODES.IDENTIFIER && child.left.name === "undefined")
4141
ast.addDiagnostic(`Expected string or number on left hand side of operation, got undefined`, DiagnosticSeverity.Error, child.left.loc!);
42-
if (child.left.type === NODES.LITERAL) {
42+
else if (child.left.type === NODES.LITERAL) {
4343
const left_type = typeof child.left.value;
4444
if (!(left_type === "string" || left_type === "number"))
4545
ast.addDiagnostic(`Expected string or number on left hand side of operation, got ${child.left.value === null ? "null" : left_type}`, DiagnosticSeverity.Error, child.left.loc!);
4646

47-
if (child.right.type === NODES.IDENTIFIER && child.right.name === "undefined")
47+
else if (child.right.type === NODES.IDENTIFIER && child.right.name === "undefined")
4848
ast.addDiagnostic(`Expected ${left_type} on left hand side of operation, got undefined`, DiagnosticSeverity.Error, child.right.loc!);
49-
if (child.right.type === NODES.LITERAL) {
49+
else if (child.right.type === NODES.LITERAL) {
5050
const right_type = typeof child.right.value;
5151
if (left_type !== right_type)
5252
ast.addDiagnostic(`Expected ${left_type} on right hand side of operation, got ${child.right.value === null ? "null" : right_type}`, DiagnosticSeverity.Error, child.right.loc!);

0 commit comments

Comments
 (0)