Parameterize program solving on a FunctionKind

This new flag determines whether we should introduce a new kind to
represent lambda sets, or whether lambdas should be erased. The latter
is not yet implemented.
This commit is contained in:
Ayaz Hafiz 2023-06-19 21:43:42 -05:00
parent 60c98ea5d5
commit 44c4797d9a
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58
29 changed files with 126 additions and 13 deletions

5
Cargo.lock generated
View File

@ -3351,6 +3351,7 @@ dependencies = [
"roc_parse",
"roc_region",
"roc_reporting",
"roc_solve",
"roc_target",
"roc_types",
"snafu",
@ -3591,6 +3592,7 @@ dependencies = [
"roc_mono",
"roc_packaging",
"roc_reporting",
"roc_solve",
"roc_target",
"serde",
"serial_test",
@ -3611,6 +3613,7 @@ dependencies = [
"roc_module",
"roc_packaging",
"roc_reporting",
"roc_solve",
"roc_target",
"roc_types",
]
@ -3794,6 +3797,7 @@ dependencies = [
"roc_problem",
"roc_region",
"roc_reporting",
"roc_solve",
"roc_std",
"roc_target",
"roc_types",
@ -3849,6 +3853,7 @@ dependencies = [
"roc_parse",
"roc_repl_eval",
"roc_reporting",
"roc_solve",
"roc_target",
"roc_types",
"tempfile",

View File

@ -12,6 +12,7 @@ pub fn load_module(
) -> LoadedModule {
let load_config = LoadConfig {
target_info: TargetInfo::default_x86_64(), // editor only needs type info, so this is unused
function_kind: roc_solve::FunctionKind::LambdaSet, // TODO the editor may need to dynamically change this
render: roc_reporting::report::RenderTarget::ColorTerminal,
palette: DEFAULT_PALETTE,
threading,

View File

@ -385,7 +385,7 @@ pub fn test(_matches: &ArgMatches, _triple: Triple) -> io::Result<i32> {
#[cfg(not(windows))]
pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
use roc_build::program::report_problems_monomorphized;
use roc_load::{ExecutionMode, LoadConfig, LoadMonomorphizedError};
use roc_load::{ExecutionMode, FunctionKind, LoadConfig, LoadMonomorphizedError};
use roc_packaging::cache;
use roc_target::TargetInfo;
@ -427,10 +427,13 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
let target = &triple;
let opt_level = opt_level;
let target_info = TargetInfo::from(target);
// TODO may need to determine this dynamically based on dev builds.
let function_kind = FunctionKind::LambdaSet;
// Step 1: compile the app and generate the .o file
let load_config = LoadConfig {
target_info,
function_kind,
// TODO: expose this from CLI?
render: roc_reporting::report::RenderTarget::ColorTerminal,
palette: roc_reporting::report::DEFAULT_PALETTE,

View File

@ -11,7 +11,7 @@ use roc_docs::generate_docs_html;
use roc_error_macros::user_error;
use roc_gen_dev::AssemblyBackendMode;
use roc_gen_llvm::llvm::build::LlvmBackendMode;
use roc_load::{LoadingProblem, Threading};
use roc_load::{FunctionKind, LoadingProblem, Threading};
use roc_packaging::cache::{self, RocCacheDir};
use roc_target::Target;
use std::fs::{self, FileType};
@ -123,10 +123,12 @@ fn main() -> io::Result<()> {
.get_one::<String>(FLAG_TARGET)
.and_then(|s| Target::from_str(s).ok())
.unwrap_or_default();
let function_kind = FunctionKind::LambdaSet;
roc_linker::generate_stub_lib(
input_path,
RocCacheDir::Persistent(cache::roc_cache_dir().as_path()),
&target.to_triple(),
function_kind,
)
}
Some((CMD_BUILD, matches)) => {

View File

@ -8,8 +8,8 @@ use roc_gen_dev::AssemblyBackendMode;
use roc_gen_llvm::llvm::build::{module_from_builtins, LlvmBackendMode};
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
use roc_load::{
EntryPoint, ExecutionMode, ExpectMetadata, LoadConfig, LoadMonomorphizedError, LoadedModule,
LoadingProblem, MonomorphizedModule, Threading,
EntryPoint, ExecutionMode, ExpectMetadata, FunctionKind, LoadConfig, LoadMonomorphizedError,
LoadedModule, LoadingProblem, MonomorphizedModule, Threading,
};
use roc_mono::ir::{OptLevel, SingleEntryPoint};
use roc_packaging::cache::RocCacheDir;
@ -742,6 +742,7 @@ pub fn standard_load_config(
LoadConfig {
target_info,
function_kind: FunctionKind::LambdaSet,
render: RenderTarget::ColorTerminal,
palette: DEFAULT_PALETTE,
threading,
@ -1205,6 +1206,8 @@ pub fn check_file<'a>(
let load_config = LoadConfig {
target_info,
// TODO: we may not want this for just checking.
function_kind: FunctionKind::LambdaSet,
// TODO: expose this from CLI?
render: RenderTarget::ColorTerminal,
palette: DEFAULT_PALETTE,

View File

@ -14,6 +14,7 @@ roc_load_internal = { path = "../load_internal" }
roc_module = { path = "../module" }
roc_packaging = { path = "../../packaging" }
roc_reporting = { path = "../../reporting" }
roc_solve = { path = "../solve" }
roc_target = { path = "../roc_target" }
roc_types = { path = "../types" }
@ -25,6 +26,7 @@ roc_can = { path = "../can" }
roc_module = { path = "../module" }
roc_packaging = { path = "../../packaging" }
roc_reporting = { path = "../../reporting" }
roc_solve = { path = "../solve" }
roc_target = { path = "../roc_target" }
roc_error_macros = { path = "../../error_macros" }

View File

@ -77,6 +77,7 @@ fn write_types_for_module_real(module_id: ModuleId, filename: &str, output_path:
let cwd = std::env::current_dir().unwrap();
let source = roc_builtins::roc::module_source(module_id);
let target_info = roc_target::TargetInfo::default_x86_64();
let function_kind = roc_solve::FunctionKind::LambdaSet;
let res_module = roc_load_internal::file::load_and_typecheck_str(
&arena,
@ -85,6 +86,7 @@ fn write_types_for_module_real(module_id: ModuleId, filename: &str, output_path:
cwd,
Default::default(),
target_info,
function_kind,
roc_reporting::report::RenderTarget::ColorTerminal,
roc_reporting::report::DEFAULT_PALETTE,
RocCacheDir::Disallowed,

View File

@ -24,6 +24,7 @@ pub use roc_load_internal::file::{
pub use roc_load_internal::module::{
EntryPoint, Expectations, ExposedToHost, LoadedModule, MonomorphizedModule,
};
pub use roc_solve::FunctionKind;
#[allow(clippy::too_many_arguments)]
fn load<'a>(
@ -51,6 +52,7 @@ pub fn load_single_threaded<'a>(
arena: &'a Bump,
load_start: LoadStart<'a>,
target_info: TargetInfo,
function_kind: FunctionKind,
render: RenderTarget,
palette: Palette,
roc_cache_dir: RocCacheDir<'_>,
@ -64,6 +66,7 @@ pub fn load_single_threaded<'a>(
load_start,
exposed_types,
target_info,
function_kind,
cached_subs,
render,
palette,
@ -170,6 +173,7 @@ pub fn load_and_typecheck_str<'a>(
source: &'a str,
src_dir: PathBuf,
target_info: TargetInfo,
function_kind: FunctionKind,
render: RenderTarget,
roc_cache_dir: RocCacheDir<'_>,
palette: Palette,
@ -185,6 +189,7 @@ pub fn load_and_typecheck_str<'a>(
arena,
load_start,
target_info,
function_kind,
render,
palette,
roc_cache_dir,

View File

@ -63,6 +63,7 @@ use roc_region::all::{LineInfo, Loc, Region};
use roc_reporting::report::to_https_problem_report_string;
use roc_reporting::report::{to_file_problem_report_string, Palette, RenderTarget};
use roc_solve::module::{extract_module_owned_implementations, SolveConfig, Solved, SolvedModule};
use roc_solve::FunctionKind;
use roc_solve_problem::TypeError;
use roc_target::TargetInfo;
use roc_types::subs::{CopiedImport, ExposedTypesStorageSubs, Subs, VarStore, Variable};
@ -113,6 +114,7 @@ pub struct LoadConfig {
pub palette: Palette,
pub threading: Threading,
pub exec_mode: ExecutionMode,
pub function_kind: FunctionKind,
}
#[derive(Debug, Clone, Copy)]
@ -679,6 +681,8 @@ struct State<'a> {
pub output_path: Option<&'a str>,
pub platform_path: PlatformPath<'a>,
pub target_info: TargetInfo,
#[allow(unused)] // for now
pub(self) function_kind: FunctionKind,
/// Note: only packages and platforms actually expose any modules;
/// for all others, this will be empty.
@ -740,6 +744,7 @@ impl<'a> State<'a> {
root_id: ModuleId,
opt_platform_shorthand: Option<&'a str>,
target_info: TargetInfo,
function_kind: FunctionKind,
exposed_types: ExposedByModule,
arc_modules: Arc<Mutex<PackageModuleIds<'a>>>,
ident_ids_by_module: SharedIdentIdsByModule,
@ -759,6 +764,7 @@ impl<'a> State<'a> {
opt_platform_shorthand,
cache_dir,
target_info,
function_kind,
platform_data: None,
output_path: None,
platform_path: PlatformPath::NotSpecified,
@ -969,6 +975,7 @@ pub fn load_and_typecheck_str<'a>(
src_dir: PathBuf,
exposed_types: ExposedByModule,
target_info: TargetInfo,
function_kind: FunctionKind,
render: RenderTarget,
palette: Palette,
roc_cache_dir: RocCacheDir<'_>,
@ -988,6 +995,7 @@ pub fn load_and_typecheck_str<'a>(
palette,
threading,
exec_mode: ExecutionMode::Check,
function_kind,
};
match load(
@ -1243,6 +1251,7 @@ pub fn load<'a>(
load_start,
exposed_types,
load_config.target_info,
load_config.function_kind,
cached_types,
load_config.render,
load_config.palette,
@ -1254,6 +1263,7 @@ pub fn load<'a>(
load_start,
exposed_types,
load_config.target_info,
load_config.function_kind,
cached_types,
load_config.render,
load_config.palette,
@ -1270,6 +1280,7 @@ pub fn load_single_threaded<'a>(
load_start: LoadStart<'a>,
exposed_types: ExposedByModule,
target_info: TargetInfo,
function_kind: FunctionKind,
cached_types: MutMap<ModuleId, TypeState>,
render: RenderTarget,
palette: Palette,
@ -1297,6 +1308,7 @@ pub fn load_single_threaded<'a>(
root_id,
opt_platform_shorthand,
target_info,
function_kind,
exposed_types,
arc_modules,
ident_ids_by_module,
@ -1584,6 +1596,7 @@ fn load_multi_threaded<'a>(
load_start: LoadStart<'a>,
exposed_types: ExposedByModule,
target_info: TargetInfo,
function_kind: FunctionKind,
cached_types: MutMap<ModuleId, TypeState>,
render: RenderTarget,
palette: Palette,
@ -1627,6 +1640,7 @@ fn load_multi_threaded<'a>(
root_id,
opt_platform_shorthand,
target_info,
function_kind,
exposed_types,
arc_modules,
ident_ids_by_module,

View File

@ -29,6 +29,7 @@ use roc_region::all::LineInfo;
use roc_reporting::report::RenderTarget;
use roc_reporting::report::RocDocAllocator;
use roc_reporting::report::{can_problem, DEFAULT_PALETTE};
use roc_solve::FunctionKind;
use roc_target::TargetInfo;
use roc_types::pretty_print::name_and_print_var;
use roc_types::pretty_print::DebugPrint;
@ -40,6 +41,7 @@ fn load_and_typecheck(
filename: PathBuf,
exposed_types: ExposedByModule,
target_info: TargetInfo,
function_kind: FunctionKind,
) -> Result<LoadedModule, LoadingProblem> {
use LoadResult::*;
@ -52,6 +54,7 @@ fn load_and_typecheck(
)?;
let load_config = LoadConfig {
target_info,
function_kind,
render: RenderTarget::Generic,
palette: DEFAULT_PALETTE,
threading: Threading::Single,
@ -176,7 +179,13 @@ fn multiple_modules_help<'a>(
writeln!(file, "{source}")?;
file_handles.push(file);
load_and_typecheck(arena, full_file_path, Default::default(), TARGET_INFO)
load_and_typecheck(
arena,
full_file_path,
Default::default(),
TARGET_INFO,
FunctionKind::LambdaSet,
)
};
Ok(result)
@ -190,7 +199,13 @@ fn load_fixture(
let src_dir = fixtures_dir().join(dir_name);
let filename = src_dir.join(format!("{module_name}.roc"));
let arena = Bump::new();
let loaded = load_and_typecheck(&arena, filename, subs_by_module, TARGET_INFO);
let loaded = load_and_typecheck(
&arena,
filename,
subs_by_module,
TARGET_INFO,
FunctionKind::LambdaSet,
);
let mut loaded_module = match loaded {
Ok(x) => x,
Err(roc_load_internal::file::LoadingProblem::FormattedReport(report)) => {
@ -347,7 +362,13 @@ fn interface_with_deps() {
let src_dir = fixtures_dir().join("interface_with_deps");
let filename = src_dir.join("Primary.roc");
let arena = Bump::new();
let loaded = load_and_typecheck(&arena, filename, subs_by_module, TARGET_INFO);
let loaded = load_and_typecheck(
&arena,
filename,
subs_by_module,
TARGET_INFO,
FunctionKind::LambdaSet,
);
let mut loaded_module = loaded.expect("Test module failed to load");
let home = loaded_module.module_id;

View File

@ -0,0 +1,8 @@
/// How function kinds should be represented in the type system.
#[derive(Debug)]
pub enum FunctionKind {
/// Function values are solved to lambda sets; lambda sets are the kind.
LambdaSet,
/// Function values are erased, no kind is introduced.
Erased,
}

View File

@ -14,9 +14,11 @@ pub mod specialize;
mod aliases;
mod deep_copy;
mod env;
mod kinds;
mod pools;
mod to_var;
pub use aliases::Aliases;
pub use env::{DerivedEnv, Env};
pub use kinds::FunctionKind;
pub use pools::Pools;

View File

@ -3,7 +3,10 @@ use std::path::PathBuf;
use bumpalo::Bump;
use roc_packaging::cache::RocCacheDir;
use roc_solve::module::{SolveConfig, SolveOutput};
use roc_solve::{
module::{SolveConfig, SolveOutput},
FunctionKind,
};
use ven_pretty::DocAllocator;
use roc_can::{
@ -520,6 +523,7 @@ where
path.parent().unwrap().to_path_buf(),
Default::default(),
target_info,
FunctionKind::LambdaSet,
roc_reporting::report::RenderTarget::ColorTerminal,
roc_reporting::report::DEFAULT_PALETTE,
RocCacheDir::Disallowed,

View File

@ -8,7 +8,9 @@ use roc_collections::all::MutSet;
use roc_command_utils::zig;
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult};
use roc_load::{EntryPoint, ExecutionMode, LoadConfig, LoadMonomorphizedError, Threading};
use roc_load::{
EntryPoint, ExecutionMode, FunctionKind, LoadConfig, LoadMonomorphizedError, Threading,
};
use roc_mono::ir::{CrashTag, OptLevel, SingleEntryPoint};
use roc_packaging::cache::RocCacheDir;
use roc_region::all::LineInfo;
@ -52,6 +54,8 @@ fn create_llvm_module<'a>(
target: &Triple,
) -> (&'static str, String, &'a Module<'a>) {
let target_info = roc_target::TargetInfo::from(target);
// TODO parameterize
let function_kind = FunctionKind::LambdaSet;
let filename = PathBuf::from("Test.roc");
let src_dir = PathBuf::from("fake/test/path");
@ -69,6 +73,7 @@ fn create_llvm_module<'a>(
let load_config = LoadConfig {
target_info,
function_kind,
render: RenderTarget::ColorTerminal,
palette: DEFAULT_PALETTE,
threading: Threading::Single,

View File

@ -16,6 +16,7 @@ const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024;
use bumpalo::Bump;
use roc_collections::all::MutMap;
use roc_load::ExecutionMode;
use roc_load::FunctionKind;
use roc_load::LoadConfig;
use roc_load::LoadMonomorphizedError;
use roc_load::Threading;
@ -104,6 +105,8 @@ fn compiles_to_ir(test_name: &str, src: &str, mode: &str, allow_type_errors: boo
let load_config = LoadConfig {
target_info: TARGET_INFO,
// TODO parameterize
function_kind: FunctionKind::LambdaSet,
threading: Threading::Single,
render: roc_reporting::report::RenderTarget::Generic,
palette: roc_reporting::report::DEFAULT_PALETTE,

View File

@ -79,6 +79,8 @@ pub fn run_load_and_infer<'a>(
module_src,
dir.path().to_path_buf(),
roc_target::TargetInfo::default_x86_64(),
// TODO parameterize me!
roc_solve::FunctionKind::LambdaSet,
roc_reporting::report::RenderTarget::Generic,
RocCacheDir::Disallowed,
roc_reporting::report::DEFAULT_PALETTE,

View File

@ -8,6 +8,7 @@ use roc_mono::{
ir::{Proc, ProcLayout},
layout::STLayoutInterner,
};
use roc_solve::FunctionKind;
use tempfile::tempdir;
use test_solve_helpers::format_problems;
@ -41,6 +42,8 @@ pub fn write_compiled_ir<'a>(
let load_config = LoadConfig {
target_info: roc_target::TargetInfo::default_x86_64(),
// TODO parameterize
function_kind: FunctionKind::LambdaSet,
threading: Threading::Single,
render: roc_reporting::report::RenderTarget::Generic,
palette: roc_reporting::report::DEFAULT_PALETTE,

View File

@ -20,6 +20,7 @@ roc_packaging = { path = "../packaging" }
roc_parse = { path = "../compiler/parse" }
roc_region = { path = "../compiler/region" }
roc_reporting = { path = "../reporting" }
roc_solve = { path = "../compiler/solve" }
roc_target = { path = "../compiler/roc_target" }
roc_types = { path = "../compiler/types" }

View File

@ -454,6 +454,7 @@ pub fn load_module_for_docs(filename: PathBuf) -> LoadedModule {
let arena = Bump::new();
let load_config = LoadConfig {
target_info: roc_target::TargetInfo::default_x86_64(), // This is just type-checking for docs, so "target" doesn't matter
function_kind: roc_solve::FunctionKind::LambdaSet,
render: roc_reporting::report::RenderTarget::ColorTerminal,
palette: roc_reporting::report::DEFAULT_PALETTE,
threading: Threading::AllAvailable,

View File

@ -10,7 +10,7 @@ use roc_build::{
},
};
use roc_collections::MutMap;
use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threading};
use roc_load::{ExecutionMode, FunctionKind, LoadConfig, LoadedModule, LoadingProblem, Threading};
use roc_mono::ir::{generate_glue_procs, GlueProc, OptLevel};
use roc_mono::layout::{GlobalLayoutInterner, LayoutCache, LayoutInterner};
use roc_packaging::cache::{self, RocCacheDir};
@ -334,6 +334,8 @@ pub fn load_types(
ignore_errors: IgnoreErrors,
) -> Result<Vec<Types>, io::Error> {
let target_info = (&Triple::host()).into();
// TODO the function kind may need to be parameterizable.
let function_kind = FunctionKind::LambdaSet;
let arena = &Bump::new();
let LoadedModule {
module_id: home,
@ -350,6 +352,7 @@ pub fn load_types(
RocCacheDir::Persistent(cache::roc_cache_dir().as_path()),
LoadConfig {
target_info,
function_kind,
render: RenderTarget::Generic,
palette: DEFAULT_PALETTE,
threading,

View File

@ -20,6 +20,7 @@ roc_load = { path = "../compiler/load" }
roc_mono = { path = "../compiler/mono" }
roc_packaging = { path = "../packaging" }
roc_reporting = { path = "../reporting" }
roc_solve = { path = "../compiler/solve" }
roc_target = { path = "../compiler/roc_target" }
bincode.workspace = true

View File

@ -10,6 +10,7 @@ use roc_load::{EntryPoint, ExecutionMode, ExposedToHost, LoadConfig, Threading};
use roc_module::symbol::Interns;
use roc_packaging::cache::RocCacheDir;
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
use roc_solve::FunctionKind;
use roc_target::get_target_triple_str;
use std::cmp::Ordering;
use std::mem;
@ -88,6 +89,7 @@ pub fn generate_stub_lib(
input_path: &Path,
roc_cache_dir: RocCacheDir<'_>,
triple: &Triple,
function_kind: FunctionKind,
) -> std::io::Result<i32> {
// Note: this should theoretically just be able to load the host, I think.
// Instead, I am loading an entire app because that was simpler and had example code.
@ -101,6 +103,7 @@ pub fn generate_stub_lib(
roc_cache_dir,
LoadConfig {
target_info,
function_kind,
render: RenderTarget::Generic,
palette: DEFAULT_PALETTE,
threading: Threading::AllAvailable,

View File

@ -7,7 +7,7 @@ use roc_error_macros::internal_error;
use roc_gen_llvm::llvm::build::LlvmBackendMode;
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
use roc_gen_llvm::{run_jit_function, run_jit_function_dynamic_type};
use roc_load::{EntryPoint, MonomorphizedModule};
use roc_load::{EntryPoint, FunctionKind, MonomorphizedModule};
use roc_mono::ir::OptLevel;
use roc_mono::layout::STLayoutInterner;
use roc_parse::ast::Expr;
@ -29,11 +29,19 @@ pub fn gen_and_eval_llvm<'a, I: Iterator<Item = &'a str>>(
) -> (Option<ReplOutput>, Problems) {
let arena = Bump::new();
let target_info = TargetInfo::from(&target);
let function_kind = FunctionKind::LambdaSet;
let mut loaded;
let problems;
match compile_to_mono(&arena, defs, src, target_info, DEFAULT_PALETTE) {
match compile_to_mono(
&arena,
defs,
src,
target_info,
function_kind,
DEFAULT_PALETTE,
) {
(Some(mono), probs) => {
loaded = mono;
problems = probs;

View File

@ -20,6 +20,7 @@ roc_parse = { path = "../compiler/parse" }
roc_problem = { path = "../compiler/problem" }
roc_region = { path = "../compiler/region" }
roc_reporting = { path = "../reporting" }
roc_solve = { path = "../compiler/solve" }
roc_std = { path = "../roc_std" }
roc_target = { path = "../compiler/roc_target" }
roc_types = { path = "../compiler/types" }

View File

@ -11,6 +11,7 @@ use roc_load::{LoadingProblem, MonomorphizedModule};
use roc_parse::ast::Expr;
use roc_region::all::LineInfo;
use roc_reporting::report::{can_problem, type_problem, RocDocAllocator};
use roc_solve::FunctionKind;
use roc_target::TargetInfo;
#[derive(Debug)]
@ -49,6 +50,7 @@ pub fn compile_to_mono<'a, 'i, I: Iterator<Item = &'i str>>(
defs: I,
expr: &str,
target_info: TargetInfo,
function_kind: FunctionKind,
palette: Palette,
) -> (Option<MonomorphizedModule<'a>>, Problems) {
let filename = PathBuf::from("");
@ -62,6 +64,7 @@ pub fn compile_to_mono<'a, 'i, I: Iterator<Item = &'i str>>(
RocCacheDir::Persistent(cache::roc_cache_dir().as_path()),
LoadConfig {
target_info,
function_kind,
render: roc_reporting::report::RenderTarget::ColorTerminal,
palette,
threading: Threading::Single,

View File

@ -95,7 +95,7 @@ mod test {
use pretty_assertions::assert_eq;
use roc_error_macros::internal_error;
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult, run_roc_dylib};
use roc_load::{ExecutionMode, LoadConfig, LoadMonomorphizedError, Threading};
use roc_load::{ExecutionMode, FunctionKind, LoadConfig, LoadMonomorphizedError, Threading};
use roc_packaging::cache::RocCacheDir;
use roc_reporting::report::{RenderTarget, DEFAULT_PALETTE};
use target_lexicon::Triple;
@ -113,6 +113,7 @@ mod test {
let opt_level = roc_mono::ir::OptLevel::Normal;
let target_info = TargetInfo::from(target);
let function_kind = FunctionKind::LambdaSet;
// Step 1: compile the app and generate the .o file
let src_dir = tempfile::tempdir().unwrap();
@ -122,6 +123,7 @@ mod test {
let load_config = LoadConfig {
target_info,
function_kind,
render: RenderTarget::ColorTerminal,
palette: DEFAULT_PALETTE,
threading: Threading::Single,

View File

@ -32,6 +32,7 @@ roc_load = { path = "../compiler/load" }
roc_parse = { path = "../compiler/parse" }
roc_repl_eval = { path = "../repl_eval" }
roc_reporting = { path = "../reporting" }
roc_solve = { path = "../compiler/solve" }
roc_target = { path = "../compiler/roc_target" }
roc_types = { path = "../compiler/types" }

View File

@ -180,6 +180,7 @@ pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
// Compile the app
let target_info = TargetInfo::default_wasm32();
let function_kind = roc_solve::FunctionKind::LambdaSet;
// TODO use this to filter out problems and warnings in wrapped defs.
// See the variable by the same name in the CLI REPL for how to do this!
let mono = match compile_to_mono(
@ -187,6 +188,7 @@ pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
std::iter::empty(),
&src,
target_info,
function_kind,
DEFAULT_PALETTE_HTML,
) {
(Some(m), problems) if problems.is_empty() => m, // TODO render problems and continue if possible

View File

@ -26,6 +26,7 @@ mod test_reporting {
DEFAULT_PALETTE,
};
use roc_reporting::report::{RocDocAllocator, RocDocBuilder};
use roc_solve::FunctionKind;
use roc_solve_problem::TypeError;
use roc_types::subs::Subs;
use std::path::PathBuf;
@ -127,6 +128,7 @@ mod test_reporting {
palette: DEFAULT_PALETTE,
threading: Threading::Single,
exec_mode: ExecutionMode::Check,
function_kind: FunctionKind::LambdaSet,
};
let result = roc_load::load_and_typecheck(
arena,