remove trailing return in trailing if expression

This commit is contained in:
davidsemakula 2024-01-31 06:46:48 +03:00
parent 2987fac76f
commit cad222ff1b
2 changed files with 66 additions and 0 deletions

View file

@ -266,6 +266,12 @@ impl ExprValidator {
self.check_for_trailing_return(last_stmt, body);
}
}
Expr::If { then_branch, else_branch, .. } => {
self.check_for_trailing_return(*then_branch, body);
if let Some(else_branch) = else_branch {
self.check_for_trailing_return(*else_branch, body);
}
}
Expr::Return { .. } => {
self.diagnostics.push(BodyValidationDiagnostic::RemoveTrailingReturn {
return_expr: body_expr,