mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
#4119 Add error when doing {.A | .B} instead of {.A, .B} with a suggestion to do surround it in parentheses to make it clear it is intended
This commit is contained in:
@@ -10055,6 +10055,22 @@ gb_internal ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *
|
|||||||
is_constant = o->mode == Addressing_Constant;
|
is_constant = o->mode == Addressing_Constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elem->kind == Ast_BinaryExpr) {
|
||||||
|
switch (elem->BinaryExpr.op.kind) {
|
||||||
|
case Token_Or:
|
||||||
|
{
|
||||||
|
gbString x = expr_to_string(elem->BinaryExpr.left);
|
||||||
|
gbString y = expr_to_string(elem->BinaryExpr.right);
|
||||||
|
gbString e = expr_to_string(elem);
|
||||||
|
error(elem, "Was the following intended? '%s, %s'; if not, surround the expression with parentheses '(%s)'", x, y, e);
|
||||||
|
gb_string_free(e);
|
||||||
|
gb_string_free(y);
|
||||||
|
gb_string_free(x);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
check_assignment(c, o, t->BitSet.elem, str_lit("bit_set literal"));
|
check_assignment(c, o, t->BitSet.elem, str_lit("bit_set literal"));
|
||||||
if (o->mode == Addressing_Constant) {
|
if (o->mode == Addressing_Constant) {
|
||||||
i64 lower = t->BitSet.lower;
|
i64 lower = t->BitSet.lower;
|
||||||
|
|||||||
Reference in New Issue
Block a user