E0063#
Warning name: syntax_lint
Syntax lint warning.
This warning is emitted for code patterns that are valid but discouraged by the compiler's syntax lints.
Erroneous example#
suberror DivError { DivError(String) }
fn div(x : Int, y : Int) -> Int raise DivError {
if y == 0 {
raise DivError("division by zero")
}
x / y
}
test {
let res = match (try? div(6, 0)) {
Ok(v) => v
Err(_) => 0
}
inspect(res, content="0")
}
Suggestion#
Follow the suggestion in the compiler lint message.
suberror DivError { DivError(String) }
fn div(x : Int, y : Int) -> Int raise DivError {
if y == 0 {
raise DivError("division by zero")
}
x / y
}
test {
try div(6, 0) catch {
DivError(_) => inspect(0, content="0")
} noraise {
v => inspect(v, content="0")
}
}