Merge pull request #3478 from rtfeldman/toplevel-expect-captures

toplevel expect captures
This commit is contained in:
Richard Feldman 2022-07-12 08:58:19 -04:00 committed by GitHub
commit c61795197f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 221 additions and 75 deletions

View file

@ -4313,24 +4313,10 @@ pub fn build_procedures_return_main<'a, 'ctx, 'env>(
pub fn build_procedures_expose_expects<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
opt_level: OptLevel,
expects: &[Symbol],
procedures: MutMap<(Symbol, ProcLayout<'a>), roc_mono::ir::Proc<'a>>,
entry_point: EntryPoint<'a>,
) -> Vec<'a, &'a str> {
use bumpalo::collections::CollectIn;
// this is not entirely accurate: it will treat every top-level bool value (turned into a
// zero-argument thunk) as an expect.
let expects: Vec<_> = procedures
.keys()
.filter_map(|(symbol, proc_layout)| {
if proc_layout.arguments.is_empty() && proc_layout.result == Layout::bool() {
Some(*symbol)
} else {
None
}
})
.collect_in(env.arena);
let mod_solutions = build_procedures_help(
env,
opt_level,
@ -4343,7 +4329,7 @@ pub fn build_procedures_expose_expects<'a, 'ctx, 'env>(
let top_level = ProcLayout {
arguments: &[],
result: Layout::bool(),
result: Layout::UNIT,
captures_niche,
};