diff options
| author | gingerBill <bill@gingerbill.org> | 2024-05-09 15:56:00 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-05-09 15:56:00 +0100 |
| commit | f54977336b27c32eab52b77d94e7b1610f4350cf (patch) | |
| tree | a32a7e6647b095cefb240bf8902f78f6ade8adc0 /src/check_expr.cpp | |
| parent | b0f0e4d02a88b27e04d9d7241959107ce08ff592 (diff) | |
With `-vet-style`, give suggestion of separating where clauses with a comma rather than '&&'
This improves the error messages
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 013638e63..98aebfe4e 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -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); + } + } + } } |