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

@ -5878,6 +5878,28 @@ pub fn with_hole<'a>(
}
}
}
Return {
return_value,
return_var,
} => {
let return_symbol = possible_reuse_symbol_or_specialize(
env,
procs,
layout_cache,
&return_value.value,
return_var,
);
assign_to_symbol(
env,
procs,
layout_cache,
return_var,
*return_value,
return_symbol,
Stmt::Ret(return_symbol),
)
}
TypedHole(_) => runtime_error(env, "Hit a blank"),
RuntimeError(e) => runtime_error(env, env.arena.alloc(e.runtime_message())),
Crash { msg, ret_var: _ } => {