Implement return keyword

This commit is contained in:
Sam Mohr 2024-10-20 04:50:12 -07:00
parent 20a539a96d
commit b3e60f9d3a
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
39 changed files with 594 additions and 80 deletions

View file

@ -369,6 +369,12 @@ pub fn canonicalize_module_defs<'a>(
PatternType::TopLevelDef,
);
for (_early_return_var, early_return_region) in &scope.early_returns {
env.problem(Problem::ReturnOutsideOfFunction {
region: *early_return_region,
});
}
let pending_derives = output.pending_derives;
// See if any of the new idents we defined went unused.
@ -425,7 +431,7 @@ pub fn canonicalize_module_defs<'a>(
..Default::default()
};
let (mut declarations, mut output) = crate::def::sort_can_defs_new(
let (mut declarations, mut output) = crate::def::sort_top_level_can_defs(
&mut env,
&mut scope,
var_store,
@ -969,6 +975,14 @@ fn fix_values_captured_in_closure_expr(
);
}
Return { return_value, .. } => {
fix_values_captured_in_closure_expr(
&mut return_value.value,
no_capture_symbols,
closure_captures,
);
}
Crash { msg, ret_var: _ } => {
fix_values_captured_in_closure_expr(
&mut msg.value,