DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page
B0109: mixed logical operators need parentheses
Catalog status: active. Default severity: error. Stable name: mixed-logical-operators. Family: Syntax and source text.
Ada does not give and, or and xor (or their short-circuit forms and then and or else) a precedence relative to each other: an expression that mixes them must say how they group, with parentheses (RM 4.4). This rules out a classic source of mistakes.
Example (Vada)
A := A and B or C;Example (Varc)
a = a && b || c;
What to do (Vada)
A := (A and B) or C;What to do (Varc)
a = (a && b) || c;
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See syntax and source text, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.