XO0163: unparenthesized struct literal in a condition
In the condition of if, while, for, match, requires, or ensures, a { opens the body, so a struct literal or struct pattern (p is Point{x: 0, ..}) there is ambiguous. Parenthesize the condition, as in Go. The diagnostic carries that fix. See core 1.4.
Example
struct Point { x: Int }
fn f(p: Point) -> Bool {
if p == Point{x: 0} {
true
} else {
false
}
}Fix
struct Point { x: Int }
fn f(p: Point) -> Bool {
if (p == Point{x: 0}) {
true
} else {
false
}
}Run xo explain XO0163 for this text in a terminal, or see
section 10.6 of the specification.