make an inline expect triggered by a top-level expect work

This commit is contained in:
Folkert 2024-01-31 23:26:12 +01:00
parent 39a90ec32d
commit 41ad915c35
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
5 changed files with 84 additions and 40 deletions

View file

@ -4,7 +4,7 @@ use {
roc_module::symbol::Interns,
roc_mono::{
ir::ProcLayout,
layout::{GlobalLayoutInterner, LayoutCache, Niche},
layout::{GlobalLayoutInterner, LayoutCache, LayoutInterner, Niche},
},
roc_parse::ast::Expr,
roc_repl_eval::{eval::jit_to_ast, ReplAppMemory},
@ -57,30 +57,30 @@ pub fn get_values<'a>(
app.offset = start;
let expr = {
// TODO: pass layout_cache to jit_to_ast directly
let mut layout_cache = LayoutCache::new(layout_interner.fork(), target_info);
let layout = layout_cache.from_var(arena, variable, subs).unwrap();
// TODO: pass layout_cache to jit_to_ast directly
let mut layout_cache = LayoutCache::new(layout_interner.fork(), target_info);
let layout = layout_cache.from_var(arena, variable, subs).unwrap();
let proc_layout = ProcLayout {
arguments: &[],
result: layout,
niche: Niche::NONE,
};
jit_to_ast(
arena,
app,
"expect_repl_main_fn",
proc_layout,
variable,
subs,
interns,
layout_interner.fork(),
target_info,
)
let proc_layout = ProcLayout {
arguments: &[],
result: layout,
niche: Niche::NONE,
};
let expr = jit_to_ast(
arena,
app,
"expect_repl_main_fn",
proc_layout,
variable,
subs,
interns,
layout_interner.fork(),
target_info,
);
app.offset += layout_cache.interner.stack_size_and_alignment(layout).0 as usize;
result.push(expr);
result_vars.push(variable);
}

View file

@ -273,7 +273,7 @@ fn run_expect_pure<'a, W: std::io::Write>(
let mut offset = ExpectSequence::START_OFFSET;
for _ in 0..sequence.count_failures() {
offset += render_expect_failure(
offset = render_expect_failure(
writer,
&renderer,
arena,
@ -731,5 +731,9 @@ pub fn expect_mono_module_to_dylib<'a>(
);
}
if let Ok(path) = std::env::var("ROC_DEBUG_LLVM") {
env.module.print_to_file(path).unwrap();
}
llvm_module_to_dylib(env.module, &target, opt_level).map(|lib| (lib, expects, layout_interner))
}