Diagnostics
The v0.40.x cycle added or formalized four conditional diagnostics. Each one targets a specific, common mistake and points at the fix.
ARIA-IF-001 — stray else
A leading else or else if with no preceding if:
else { // ERROR ARIA-IF-001
println("orphan");
};
Before this diagnostic, a stray else fell through to expression parsing and
produced a confusing "Expected expression / found token else" cascade. Now the
parser recognizes the orphaned else directly and tells you it has no matching
if. Fix: add the if clause it belongs to, or delete the stray else.
ARIA-IF-002 — assignment used as a condition
An assignment (=) where a condition is expected — almost always a typo for the
equality test ==:
if (x = 3i32) { ... }; // ERROR ARIA-IF-002: did you mean `==`?
Because Nitpick conditions are strictly bool, an assignment could never be a
valid condition, so the compiler can confidently suggest ==. This fires for
both if and else if conditions. The equality test is unaffected:
if (x == 3i32) { ... }; // OK
ARIA-IF-003 — if used as an expression
An if statement placed where a value is expected — an initializer, a function
argument, or a return position:
int32:x = if (c) { 1i32 } else { 2i32 }; // ERROR ARIA-IF-003
if is a statement and never yields a value. The diagnostic points you at the
two value-producing conditionals:
int32:x = is (c) : 1i32 : 2i32; // the is ternary
int32:y = pick (c) { (true){ give 1i32; }, (*){ give 2i32; } }; // pick + give
while and for in expression position keep the older generic "this is a
statement" hint, because they have no value-producing counterpart.
ARIA-IS-001 — incompatible is arms
The two arms of an is ternary have incompatible types:
int32:x = is (c) : 1i32 : "two"; // ERROR ARIA-IS-001
Both arms must share a common type, which becomes the type of the whole expression. Integer arms of different widths are fine (the narrower is widened); mixing a number with a string is not. Fix: make both arms the same kind of value.
Summary
| Code | Trigger | Fix |
|---|---|---|
ARIA-IF-001 |
else / else if with no if |
add the if, or remove else |
ARIA-IF-002 |
= used as a condition |
use == |
ARIA-IF-003 |
if used in value position |
use is or pick + give |
ARIA-IS-001 |
incompatible is arms |
make both arms compatible |