Implement most of the recent round of PR feedback

This commit is contained in:
Sam Mohr 2024-10-26 04:17:50 -07:00
parent 03f83a0ba8
commit 6a2ffb2f5a
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
13 changed files with 67 additions and 116 deletions

View file

@ -1280,8 +1280,11 @@ pub fn canonicalize_expr<'a>(
);
if let Some(after_return) = after_return {
let region_with_return =
Region::span_across(&return_expr.region, &after_return.region);
env.problem(Problem::StatementsAfterReturn {
region: after_return.region,
region: region_with_return,
});
}
@ -1649,6 +1652,17 @@ fn canonicalize_closure_body<'a>(
}
}
let final_expr = match &loc_body_expr.value {
Expr::LetRec(_, final_expr, _) | Expr::LetNonRec(_, final_expr) => &final_expr.value,
_ => &loc_body_expr.value,
};
if let Expr::Return { return_value, .. } = final_expr {
env.problem(Problem::ReturnAtEndOfFunction {
region: return_value.region,
});
}
// store the references of this function in the Env. This information is used
// when we canonicalize a surrounding def (if it exists)
env.closures.insert(symbol, output.references.clone());