diff --git a/cli/src/repl.rs b/cli/src/repl.rs index 2a5548e8ee..5cb1285b9d 100644 --- a/cli/src/repl.rs +++ b/cli/src/repl.rs @@ -257,7 +257,9 @@ pub fn gen(src: &[u8], target: Triple, opt_level: OptLevel) -> Result<(String, S ident_ids: &mut ident_ids, }; - let main_body = roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs); + let mut layout_cache = LayoutCache::default(); + let main_body = + roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs, &mut layout_cache); let main_body = roc_mono::inc_dec::visit_declaration(mono_env.arena, mono_env.arena.alloc(main_body)); let mut headers = { diff --git a/compiler/gen/tests/helpers/eval.rs b/compiler/gen/tests/helpers/eval.rs index 92ca7f7fd1..2f02e81df4 100644 --- a/compiler/gen/tests/helpers/eval.rs +++ b/compiler/gen/tests/helpers/eval.rs @@ -13,7 +13,7 @@ pub fn helper_without_uniqueness<'a>( use roc_gen::llvm::build::Scope; use roc_gen::llvm::build::{build_proc, build_proc_header}; use roc_gen::llvm::convert::basic_type_from_layout; - use roc_mono::layout::Layout; + use roc_mono::layout::{Layout, LayoutCache}; let target = target_lexicon::Triple::host(); let ptr_bytes = target.pointer_width().unwrap().bytes() as u32; @@ -105,7 +105,9 @@ pub fn helper_without_uniqueness<'a>( ident_ids: &mut ident_ids, }; - let main_body = roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs); + let mut layout_cache = LayoutCache::default(); + let main_body = + roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs, &mut layout_cache); let main_body = roc_mono::inc_dec::visit_declaration(mono_env.arena, mono_env.arena.alloc(main_body)); @@ -214,7 +216,7 @@ pub fn helper_with_uniqueness<'a>( use roc_gen::llvm::build::Scope; use roc_gen::llvm::build::{build_proc, build_proc_header}; use roc_gen::llvm::convert::basic_type_from_layout; - use roc_mono::layout::Layout; + use roc_mono::layout::{Layout, LayoutCache}; let target = target_lexicon::Triple::host(); let ptr_bytes = target.pointer_width().unwrap().bytes() as u32; @@ -296,7 +298,9 @@ pub fn helper_with_uniqueness<'a>( ident_ids: &mut ident_ids, }; - let main_body = roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs); + let mut layout_cache = LayoutCache::default(); + let main_body = + roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs, &mut layout_cache); let main_body = roc_mono::inc_dec::visit_declaration(mono_env.arena, mono_env.arena.alloc(main_body)); let mut headers = { diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 7c690b4af4..7b5c62aae6 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -625,11 +625,11 @@ impl<'a> Stmt<'a> { env: &mut Env<'a, '_>, can_expr: roc_can::expr::Expr, procs: &mut Procs<'a>, + layout_cache: &mut LayoutCache<'a>, ) -> Self { - let mut layout_cache = LayoutCache::default(); - - from_can(env, can_expr, procs, &mut layout_cache) + from_can(env, can_expr, procs, layout_cache) } + pub fn to_doc<'b, D, A>(&'b self, alloc: &'b D) -> DocBuilder<'b, D, A> where D: DocAllocator<'b, A>, diff --git a/compiler/reporting/tests/test_reporting.rs b/compiler/reporting/tests/test_reporting.rs index 986494edc6..00ad553745 100644 --- a/compiler/reporting/tests/test_reporting.rs +++ b/compiler/reporting/tests/test_reporting.rs @@ -10,21 +10,21 @@ mod helpers; #[cfg(test)] mod test_reporting { use crate::helpers::test_home; + use crate::helpers::{can_expr, infer_expr, CanExprOut, ParseErrOut}; use bumpalo::Bump; use roc_module::symbol::{Interns, ModuleId}; use roc_mono::ir::{Procs, Stmt}; + use roc_mono::layout::LayoutCache; use roc_reporting::report::{ can_problem, mono_problem, parse_problem, type_problem, Report, BLUE_CODE, BOLD_CODE, CYAN_CODE, DEFAULT_PALETTE, GREEN_CODE, MAGENTA_CODE, RED_CODE, RESET_CODE, UNDERLINE_CODE, WHITE_CODE, YELLOW_CODE, }; + use roc_reporting::report::{RocDocAllocator, RocDocBuilder}; + use roc_solve::solve; use roc_types::pretty_print::name_all_type_vars; use roc_types::subs::Subs; use std::path::PathBuf; - // use roc_region::all; - use crate::helpers::{can_expr, infer_expr, CanExprOut, ParseErrOut}; - use roc_reporting::report::{RocDocAllocator, RocDocBuilder}; - use roc_solve::solve; fn filename_from_string(str: &str) -> PathBuf { let mut filename = PathBuf::new(); @@ -87,6 +87,7 @@ mod test_reporting { let mut ident_ids = interns.all_ident_ids.remove(&home).unwrap(); // Populate Procs and Subs, and get the low-level Expr from the canonical Expr + let mut layout_cache = LayoutCache::default(); let mut mono_env = roc_mono::ir::Env { arena: &arena, subs: &mut subs, @@ -94,7 +95,8 @@ mod test_reporting { home, ident_ids: &mut ident_ids, }; - let _mono_expr = Stmt::new(&mut mono_env, loc_expr.value, &mut procs); + let _mono_expr = + Stmt::new(&mut mono_env, loc_expr.value, &mut procs, &mut layout_cache); } Ok((unify_problems, can_problems, mono_problems, home, interns))