With -vet-style, give suggestion of separating where clauses with a comma rather than '&&'

This improves the error messages
This commit is contained in:
gingerBill
2024-05-09 15:56:00 +01:00
parent b0f0e4d02a
commit f54977336b
3 changed files with 16 additions and 2 deletions

View File

@@ -6193,6 +6193,20 @@ gb_internal bool evaluate_where_clauses(CheckerContext *ctx, Ast *call_expr, Sco
}
return false;
}
if (ast_file_vet_style(ctx->file)) {
Ast *c = unparen_expr(clause);
if (c->kind == Ast_BinaryExpr && c->BinaryExpr.op.kind == Token_CmpAnd) {
ERROR_BLOCK();
error(c, "Prefer to separate 'where' clauses with a comma rather than '&&'");
gbString x = expr_to_string(c->BinaryExpr.left);
gbString y = expr_to_string(c->BinaryExpr.right);
error_line("\tSuggestion: '%s, %s'", x, y);
gb_string_free(y);
gb_string_free(x);
}
}
}
}