mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Merge remote-tracking branch 'origin/trunk' into wasm-test-wasm3
This commit is contained in:
commit
f7d556b0d1
34 changed files with 212 additions and 162 deletions
|
@ -10,12 +10,15 @@ pub fn load_module(src_file: &Path, threading: Threading) -> LoadedModule {
|
||||||
let loaded = roc_load::load_and_typecheck(
|
let loaded = roc_load::load_and_typecheck(
|
||||||
&arena,
|
&arena,
|
||||||
src_file.to_path_buf(),
|
src_file.to_path_buf(),
|
||||||
src_file.parent().unwrap_or_else(|| {
|
src_file
|
||||||
panic!(
|
.parent()
|
||||||
"src_file {:?} did not have a parent directory but I need to have one.",
|
.unwrap_or_else(|| {
|
||||||
src_file
|
panic!(
|
||||||
)
|
"src_file {:?} did not have a parent directory but I need to have one.",
|
||||||
}),
|
src_file
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.to_path_buf(),
|
||||||
subs_by_module,
|
subs_by_module,
|
||||||
TargetInfo::default_x86_64(),
|
TargetInfo::default_x86_64(),
|
||||||
roc_reporting::report::RenderTarget::ColorTerminal,
|
roc_reporting::report::RenderTarget::ColorTerminal,
|
||||||
|
|
|
@ -4,13 +4,13 @@ use roc_load::{LoadedModule, Threading};
|
||||||
use roc_reporting::report::RenderTarget;
|
use roc_reporting::report::RenderTarget;
|
||||||
use roc_target::{Architecture, TargetInfo};
|
use roc_target::{Architecture, TargetInfo};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
use target_lexicon::Triple;
|
use target_lexicon::Triple;
|
||||||
|
|
||||||
pub fn load_types(
|
pub fn load_types(
|
||||||
full_file_path: PathBuf,
|
full_file_path: PathBuf,
|
||||||
dir: &Path,
|
dir: PathBuf,
|
||||||
threading: Threading,
|
threading: Threading,
|
||||||
) -> Result<Vec<(Types, TargetInfo)>, io::Error> {
|
) -> Result<Vec<(Types, TargetInfo)>, io::Error> {
|
||||||
let target_info = (&Triple::host()).into();
|
let target_info = (&Triple::host()).into();
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub fn main() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match load_types(input_path.clone(), &cwd, Threading::AllAvailable) {
|
match load_types(input_path.clone(), cwd, Threading::AllAvailable) {
|
||||||
Ok(types_and_targets) => {
|
Ok(types_and_targets) => {
|
||||||
let mut file = File::create(output_path.clone()).unwrap_or_else(|err| {
|
let mut file = File::create(output_path.clone()).unwrap_or_else(|err| {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub fn generate_bindings(decl_src: &str) -> String {
|
||||||
let mut file = File::create(file_path).unwrap();
|
let mut file = File::create(file_path).unwrap();
|
||||||
writeln!(file, "{}", &src).unwrap();
|
writeln!(file, "{}", &src).unwrap();
|
||||||
|
|
||||||
let result = load_types(full_file_path, dir.path(), Threading::Single);
|
let result = load_types(full_file_path, dir.path().to_path_buf(), Threading::Single);
|
||||||
|
|
||||||
dir.close().expect("Unable to close tempdir");
|
dir.close().expect("Unable to close tempdir");
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ pub fn build_file<'a>(
|
||||||
let loaded = roc_load::load_and_monomorphize(
|
let loaded = roc_load::load_and_monomorphize(
|
||||||
arena,
|
arena,
|
||||||
app_module_path.clone(),
|
app_module_path.clone(),
|
||||||
src_dir.as_path(),
|
src_dir,
|
||||||
subs_by_module,
|
subs_by_module,
|
||||||
target_info,
|
target_info,
|
||||||
// TODO: expose this from CLI?
|
// TODO: expose this from CLI?
|
||||||
|
@ -436,7 +436,7 @@ pub fn check_file(
|
||||||
let mut loaded = roc_load::load_and_typecheck(
|
let mut loaded = roc_load::load_and_typecheck(
|
||||||
arena,
|
arena,
|
||||||
roc_file_path,
|
roc_file_path,
|
||||||
src_dir.as_path(),
|
src_dir,
|
||||||
subs_by_module,
|
subs_by_module,
|
||||||
target_info,
|
target_info,
|
||||||
// TODO: expose this from CLI?
|
// TODO: expose this from CLI?
|
||||||
|
|
|
@ -367,7 +367,7 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
||||||
let loaded = roc_load::load_and_monomorphize(
|
let loaded = roc_load::load_and_monomorphize(
|
||||||
arena,
|
arena,
|
||||||
path,
|
path,
|
||||||
src_dir.as_path(),
|
src_dir,
|
||||||
subs_by_module,
|
subs_by_module,
|
||||||
target_info,
|
target_info,
|
||||||
// TODO: expose this from CLI?
|
// TODO: expose this from CLI?
|
||||||
|
|
|
@ -244,21 +244,6 @@ map_symbol_to_lowlevel_and_arity! {
|
||||||
/// lookup (if the bounds check passed). That internal function is hardcoded in code gen,
|
/// lookup (if the bounds check passed). That internal function is hardcoded in code gen,
|
||||||
/// which works fine because it doesn't involve any open tag unions.
|
/// which works fine because it doesn't involve any open tag unions.
|
||||||
|
|
||||||
/// Does a builtin depend on any other builtins?
|
|
||||||
///
|
|
||||||
/// NOTE: you are supposed to give all symbols that are relied on,
|
|
||||||
/// even those that are relied on transitively!
|
|
||||||
pub fn builtin_dependencies(symbol: Symbol) -> &'static [Symbol] {
|
|
||||||
match symbol {
|
|
||||||
Symbol::LIST_SORT_ASC => &[Symbol::LIST_SORT_WITH, Symbol::NUM_COMPARE],
|
|
||||||
Symbol::LIST_SORT_DESC => &[Symbol::LIST_SORT_WITH],
|
|
||||||
Symbol::LIST_PRODUCT => &[Symbol::LIST_WALK, Symbol::NUM_MUL],
|
|
||||||
Symbol::LIST_SUM => &[Symbol::LIST_WALK, Symbol::NUM_ADD],
|
|
||||||
Symbol::LIST_SET => &[Symbol::LIST_REPLACE],
|
|
||||||
_ => &[],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Implementation for a builtin
|
/// Implementation for a builtin
|
||||||
pub fn builtin_defs_map(symbol: Symbol, var_store: &mut VarStore) -> Option<Def> {
|
pub fn builtin_defs_map(symbol: Symbol, var_store: &mut VarStore) -> Option<Def> {
|
||||||
debug_assert!(symbol.is_builtin());
|
debug_assert!(symbol.is_builtin());
|
||||||
|
|
|
@ -415,16 +415,6 @@ pub fn canonicalize_module_defs<'a>(
|
||||||
referenced_values.extend(env.qualified_value_lookups.iter().copied());
|
referenced_values.extend(env.qualified_value_lookups.iter().copied());
|
||||||
referenced_types.extend(env.qualified_type_lookups.iter().copied());
|
referenced_types.extend(env.qualified_type_lookups.iter().copied());
|
||||||
|
|
||||||
// add any builtins used by other builtins
|
|
||||||
let transitive_builtins: Vec<Symbol> = referenced_values
|
|
||||||
.iter()
|
|
||||||
.filter(|s| s.is_builtin())
|
|
||||||
.flat_map(|s| crate::builtins::builtin_dependencies(*s))
|
|
||||||
.copied()
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
referenced_values.extend(transitive_builtins);
|
|
||||||
|
|
||||||
// NOTE previously we inserted builtin defs into the list of defs here
|
// NOTE previously we inserted builtin defs into the list of defs here
|
||||||
// this is now done later, in file.rs.
|
// this is now done later, in file.rs.
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use roc_parse::ast::{Collection, ExtractSpaces};
|
use roc_parse::ast::{Collection, CommentOrNewline, ExtractSpaces};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
annotation::{Formattable, Newlines},
|
annotation::{Formattable, Newlines},
|
||||||
spaces::{count_leading_newlines, fmt_comments_only, NewlineAt, INDENT},
|
spaces::{fmt_comments_only, NewlineAt, INDENT},
|
||||||
Buf,
|
Buf,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,24 +41,43 @@ pub fn fmt_collection<'a, 'buf, T: ExtractSpaces<'a> + Formattable>(
|
||||||
buf.push(start);
|
buf.push(start);
|
||||||
|
|
||||||
for (index, item) in items.iter().enumerate() {
|
for (index, item) in items.iter().enumerate() {
|
||||||
let item = item.extract_spaces();
|
|
||||||
let is_first_item = index == 0;
|
let is_first_item = index == 0;
|
||||||
|
let item = item.extract_spaces();
|
||||||
|
let is_only_newlines = item.before.iter().all(|s| s.is_newline());
|
||||||
|
|
||||||
buf.newline();
|
if item.before.is_empty() || is_only_newlines {
|
||||||
|
buf.ensure_ends_in_newline();
|
||||||
|
} else {
|
||||||
|
if is_first_item {
|
||||||
|
// The first item in a multiline collection always begins with exactly
|
||||||
|
// one newline (so the delimiter is at the end of its own line),
|
||||||
|
// and that newline appears before the first comment (if there is one).
|
||||||
|
buf.ensure_ends_in_newline();
|
||||||
|
} else {
|
||||||
|
if item.before.starts_with(&[CommentOrNewline::Newline]) {
|
||||||
|
buf.ensure_ends_in_newline();
|
||||||
|
}
|
||||||
|
|
||||||
if !item.before.is_empty() {
|
if item
|
||||||
let is_only_newlines = item.before.iter().all(|s| s.is_newline());
|
.before
|
||||||
|
.starts_with(&[CommentOrNewline::Newline, CommentOrNewline::Newline])
|
||||||
|
{
|
||||||
|
// If there's a comment, and it's not on the first item,
|
||||||
|
// and it's preceded by at least one blank line, maintain 1 blank line.
|
||||||
|
// (We already ensured that it ends in a newline, so this will turn that
|
||||||
|
// into a blank line.)
|
||||||
|
|
||||||
if !is_first_item
|
buf.newline();
|
||||||
&& !is_only_newlines
|
}
|
||||||
&& count_leading_newlines(item.before.iter()) > 1
|
|
||||||
{
|
|
||||||
buf.newline();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt_comments_only(buf, item.before.iter(), NewlineAt::Bottom, item_indent);
|
fmt_comments_only(buf, item.before.iter(), NewlineAt::None, item_indent);
|
||||||
|
|
||||||
|
if !is_only_newlines {
|
||||||
|
if item.before.ends_with(&[CommentOrNewline::Newline]) {
|
||||||
|
buf.newline();
|
||||||
|
}
|
||||||
|
|
||||||
if !is_only_newlines && count_leading_newlines(item.before.iter().rev()) > 0 {
|
|
||||||
buf.newline();
|
buf.newline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,21 +87,33 @@ pub fn fmt_collection<'a, 'buf, T: ExtractSpaces<'a> + Formattable>(
|
||||||
buf.push(',');
|
buf.push(',');
|
||||||
|
|
||||||
if !item.after.is_empty() {
|
if !item.after.is_empty() {
|
||||||
fmt_comments_only(buf, item.after.iter(), NewlineAt::Top, item_indent);
|
if item.after.iter().any(|s| s.is_newline()) {
|
||||||
|
buf.newline();
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt_comments_only(buf, item.after.iter(), NewlineAt::None, item_indent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if count_leading_newlines(items.final_comments().iter()) > 1 {
|
if items.final_comments().iter().any(|s| s.is_newline()) {
|
||||||
|
buf.newline();
|
||||||
|
}
|
||||||
|
|
||||||
|
if items
|
||||||
|
.final_comments()
|
||||||
|
.starts_with(&[CommentOrNewline::Newline, CommentOrNewline::Newline])
|
||||||
|
{
|
||||||
buf.newline();
|
buf.newline();
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt_comments_only(
|
fmt_comments_only(
|
||||||
buf,
|
buf,
|
||||||
items.final_comments().iter(),
|
items.final_comments().iter(),
|
||||||
NewlineAt::Top,
|
NewlineAt::None,
|
||||||
item_indent,
|
item_indent,
|
||||||
);
|
);
|
||||||
buf.newline();
|
|
||||||
|
buf.ensure_ends_in_newline();
|
||||||
buf.indent(braces_indent);
|
buf.indent(braces_indent);
|
||||||
} else {
|
} else {
|
||||||
// is_multiline == false
|
// is_multiline == false
|
||||||
|
|
|
@ -2347,8 +2347,7 @@ mod test_fmt {
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : {
|
f : {
|
||||||
x : Int *,
|
x : Int *, # comment 1
|
||||||
# comment 1
|
|
||||||
# comment 2
|
# comment 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4588,7 +4587,7 @@ mod test_fmt {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multiline_tag_union_annotation() {
|
fn multiline_tag_union_annotation_no_comments() {
|
||||||
expr_formats_same(indoc!(
|
expr_formats_same(indoc!(
|
||||||
r#"
|
r#"
|
||||||
b : [
|
b : [
|
||||||
|
@ -4694,8 +4693,7 @@ mod test_fmt {
|
||||||
b : [
|
b : [
|
||||||
True,
|
True,
|
||||||
# comment 1
|
# comment 1
|
||||||
False,
|
False, # comment 2
|
||||||
# comment 2
|
|
||||||
# comment 3
|
# comment 3
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -5082,6 +5080,38 @@ mod test_fmt {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn comments_in_multiline_tag_union_annotation() {
|
||||||
|
expr_formats_to(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
UnionAnn : [
|
||||||
|
Foo, # comment 1
|
||||||
|
Bar, # comment 2
|
||||||
|
Baz, # comment 3
|
||||||
|
# comment 4 line 1
|
||||||
|
# comment 4 line 2
|
||||||
|
]
|
||||||
|
|
||||||
|
0
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
UnionAnn : [
|
||||||
|
Foo, # comment 1
|
||||||
|
Bar, # comment 2
|
||||||
|
Baz, # comment 3
|
||||||
|
# comment 4 line 1
|
||||||
|
# comment 4 line 2
|
||||||
|
]
|
||||||
|
|
||||||
|
0
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
/// Test that everything under examples/ is formatted correctly
|
/// Test that everything under examples/ is formatted correctly
|
||||||
/// If this test fails on your diff, it probably means you need to re-format the examples.
|
/// If this test fails on your diff, it probably means you need to re-format the examples.
|
||||||
|
|
|
@ -5480,7 +5480,7 @@ fn run_low_level<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let string = load_symbol(scope, &args[0]);
|
let string = load_symbol(scope, &args[0]);
|
||||||
|
|
||||||
let result = call_bitcode_fn(env, &[string], intrinsic);
|
let result = call_bitcode_fn_fixing_for_convention(env, &[string], layout, intrinsic);
|
||||||
|
|
||||||
// zig passes the result as a packed integer sometimes, instead of a struct. So we cast
|
// zig passes the result as a packed integer sometimes, instead of a struct. So we cast
|
||||||
let expected_type = basic_type_from_layout(env, layout);
|
let expected_type = basic_type_from_layout(env, layout);
|
||||||
|
|
|
@ -40,7 +40,7 @@ fn write_subs_for_module(module_id: ModuleId, filename: &str) {
|
||||||
&arena,
|
&arena,
|
||||||
PathBuf::from(filename),
|
PathBuf::from(filename),
|
||||||
source,
|
source,
|
||||||
&src_dir,
|
src_dir,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
target_info,
|
target_info,
|
||||||
roc_reporting::report::RenderTarget::ColorTerminal,
|
roc_reporting::report::RenderTarget::ColorTerminal,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use roc_module::symbol::{ModuleId, Symbol};
|
||||||
use roc_reporting::report::RenderTarget;
|
use roc_reporting::report::RenderTarget;
|
||||||
use roc_target::TargetInfo;
|
use roc_target::TargetInfo;
|
||||||
use roc_types::subs::{Subs, Variable};
|
use roc_types::subs::{Subs, Variable};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub use roc_load_internal::docs;
|
pub use roc_load_internal::docs;
|
||||||
pub use roc_load_internal::file::{
|
pub use roc_load_internal::file::{
|
||||||
|
@ -18,7 +18,6 @@ pub use roc_load_internal::file::{
|
||||||
fn load<'a>(
|
fn load<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
src_dir: &Path,
|
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
goal_phase: Phase,
|
goal_phase: Phase,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
|
@ -30,7 +29,6 @@ fn load<'a>(
|
||||||
roc_load_internal::file::load(
|
roc_load_internal::file::load(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
goal_phase,
|
goal_phase,
|
||||||
target_info,
|
target_info,
|
||||||
|
@ -44,7 +42,6 @@ fn load<'a>(
|
||||||
pub fn load_single_threaded<'a>(
|
pub fn load_single_threaded<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
src_dir: &Path,
|
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
goal_phase: Phase,
|
goal_phase: Phase,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
|
@ -55,7 +52,6 @@ pub fn load_single_threaded<'a>(
|
||||||
roc_load_internal::file::load_single_threaded(
|
roc_load_internal::file::load_single_threaded(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
goal_phase,
|
goal_phase,
|
||||||
target_info,
|
target_info,
|
||||||
|
@ -69,7 +65,7 @@ pub fn load_and_monomorphize_from_str<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
src: &'a str,
|
src: &'a str,
|
||||||
src_dir: &Path,
|
src_dir: PathBuf,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
|
@ -77,12 +73,11 @@ pub fn load_and_monomorphize_from_str<'a>(
|
||||||
) -> Result<MonomorphizedModule<'a>, LoadingProblem<'a>> {
|
) -> Result<MonomorphizedModule<'a>, LoadingProblem<'a>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_str(arena, filename, src)?;
|
let load_start = LoadStart::from_str(arena, filename, src, src_dir)?;
|
||||||
|
|
||||||
match load(
|
match load(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
Phase::MakeSpecializations,
|
Phase::MakeSpecializations,
|
||||||
target_info,
|
target_info,
|
||||||
|
@ -94,23 +89,22 @@ pub fn load_and_monomorphize_from_str<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_and_monomorphize<'a>(
|
pub fn load_and_monomorphize(
|
||||||
arena: &'a Bump,
|
arena: &Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
src_dir: &Path,
|
src_dir: PathBuf,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
threading: Threading,
|
threading: Threading,
|
||||||
) -> Result<MonomorphizedModule<'a>, LoadingProblem<'a>> {
|
) -> Result<MonomorphizedModule<'_>, LoadingProblem<'_>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_path(arena, filename, render)?;
|
let load_start = LoadStart::from_path(arena, src_dir, filename, render)?;
|
||||||
|
|
||||||
match load(
|
match load(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
Phase::MakeSpecializations,
|
Phase::MakeSpecializations,
|
||||||
target_info,
|
target_info,
|
||||||
|
@ -122,23 +116,22 @@ pub fn load_and_monomorphize<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_and_typecheck<'a>(
|
pub fn load_and_typecheck(
|
||||||
arena: &'a Bump,
|
arena: &Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
src_dir: &Path,
|
src_dir: PathBuf,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
threading: Threading,
|
threading: Threading,
|
||||||
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
) -> Result<LoadedModule, LoadingProblem<'_>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_path(arena, filename, render)?;
|
let load_start = LoadStart::from_path(arena, src_dir, filename, render)?;
|
||||||
|
|
||||||
match load(
|
match load(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
Phase::SolveTypes,
|
Phase::SolveTypes,
|
||||||
target_info,
|
target_info,
|
||||||
|
@ -154,14 +147,14 @@ pub fn load_and_typecheck_str<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
source: &'a str,
|
source: &'a str,
|
||||||
src_dir: &Path,
|
src_dir: PathBuf,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_str(arena, filename, source)?;
|
let load_start = LoadStart::from_str(arena, filename, source, src_dir)?;
|
||||||
|
|
||||||
// NOTE: this function is meant for tests, and so we use single-threaded
|
// NOTE: this function is meant for tests, and so we use single-threaded
|
||||||
// solving so we don't use too many threads per-test. That gives higher
|
// solving so we don't use too many threads per-test. That gives higher
|
||||||
|
@ -169,7 +162,6 @@ pub fn load_and_typecheck_str<'a>(
|
||||||
match load_single_threaded(
|
match load_single_threaded(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
Phase::SolveTypes,
|
Phase::SolveTypes,
|
||||||
target_info,
|
target_info,
|
||||||
|
|
|
@ -1067,7 +1067,7 @@ pub fn load_and_typecheck_str<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
source: &'a str,
|
source: &'a str,
|
||||||
src_dir: &Path,
|
src_dir: PathBuf,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
|
@ -1075,7 +1075,7 @@ pub fn load_and_typecheck_str<'a>(
|
||||||
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_str(arena, filename, source)?;
|
let load_start = LoadStart::from_str(arena, filename, source, src_dir)?;
|
||||||
|
|
||||||
// this function is used specifically in the case
|
// this function is used specifically in the case
|
||||||
// where we want to regenerate the cached data
|
// where we want to regenerate the cached data
|
||||||
|
@ -1084,7 +1084,6 @@ pub fn load_and_typecheck_str<'a>(
|
||||||
match load(
|
match load(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
Phase::SolveTypes,
|
Phase::SolveTypes,
|
||||||
target_info,
|
target_info,
|
||||||
|
@ -1108,11 +1107,13 @@ pub struct LoadStart<'a> {
|
||||||
ident_ids_by_module: SharedIdentIdsByModule,
|
ident_ids_by_module: SharedIdentIdsByModule,
|
||||||
root_id: ModuleId,
|
root_id: ModuleId,
|
||||||
root_msg: Msg<'a>,
|
root_msg: Msg<'a>,
|
||||||
|
src_dir: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LoadStart<'a> {
|
impl<'a> LoadStart<'a> {
|
||||||
pub fn from_path(
|
pub fn from_path(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
|
mut src_dir: PathBuf,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
render: RenderTarget,
|
render: RenderTarget,
|
||||||
) -> Result<Self, LoadingProblem<'a>> {
|
) -> Result<Self, LoadingProblem<'a>> {
|
||||||
|
@ -1135,7 +1136,32 @@ impl<'a> LoadStart<'a> {
|
||||||
);
|
);
|
||||||
|
|
||||||
match res_loaded {
|
match res_loaded {
|
||||||
Ok(good) => good,
|
Ok((module_id, msg)) => {
|
||||||
|
if let Msg::Header(ModuleHeader {
|
||||||
|
module_id: header_id,
|
||||||
|
module_name,
|
||||||
|
is_root_module,
|
||||||
|
..
|
||||||
|
}) = &msg
|
||||||
|
{
|
||||||
|
debug_assert_eq!(*header_id, module_id);
|
||||||
|
debug_assert!(is_root_module);
|
||||||
|
|
||||||
|
if let ModuleNameEnum::Interface(name) = module_name {
|
||||||
|
// Interface modules can have names like Foo.Bar.Baz,
|
||||||
|
// in which case we need to adjust the src_dir to
|
||||||
|
// remove the "Bar/Baz" directories in order to correctly
|
||||||
|
// resolve this interface module's imports!
|
||||||
|
let dirs_to_pop = name.as_str().matches('.').count();
|
||||||
|
|
||||||
|
for _ in 0..dirs_to_pop {
|
||||||
|
src_dir.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(module_id, msg)
|
||||||
|
}
|
||||||
|
|
||||||
Err(LoadingProblem::ParsingFailed(problem)) => {
|
Err(LoadingProblem::ParsingFailed(problem)) => {
|
||||||
let module_ids = Arc::try_unwrap(arc_modules)
|
let module_ids = Arc::try_unwrap(arc_modules)
|
||||||
|
@ -1166,6 +1192,7 @@ impl<'a> LoadStart<'a> {
|
||||||
Ok(LoadStart {
|
Ok(LoadStart {
|
||||||
arc_modules,
|
arc_modules,
|
||||||
ident_ids_by_module,
|
ident_ids_by_module,
|
||||||
|
src_dir,
|
||||||
root_id,
|
root_id,
|
||||||
root_msg,
|
root_msg,
|
||||||
})
|
})
|
||||||
|
@ -1175,6 +1202,7 @@ impl<'a> LoadStart<'a> {
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
src: &'a str,
|
src: &'a str,
|
||||||
|
src_dir: PathBuf,
|
||||||
) -> Result<Self, LoadingProblem<'a>> {
|
) -> Result<Self, LoadingProblem<'a>> {
|
||||||
let arc_modules = Arc::new(Mutex::new(PackageModuleIds::default()));
|
let arc_modules = Arc::new(Mutex::new(PackageModuleIds::default()));
|
||||||
let root_exposed_ident_ids = IdentIds::exposed_builtins(0);
|
let root_exposed_ident_ids = IdentIds::exposed_builtins(0);
|
||||||
|
@ -1196,6 +1224,7 @@ impl<'a> LoadStart<'a> {
|
||||||
|
|
||||||
Ok(LoadStart {
|
Ok(LoadStart {
|
||||||
arc_modules,
|
arc_modules,
|
||||||
|
src_dir,
|
||||||
ident_ids_by_module,
|
ident_ids_by_module,
|
||||||
root_id,
|
root_id,
|
||||||
root_msg,
|
root_msg,
|
||||||
|
@ -1269,7 +1298,6 @@ pub enum Threading {
|
||||||
pub fn load<'a>(
|
pub fn load<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
src_dir: &Path,
|
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
goal_phase: Phase,
|
goal_phase: Phase,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
|
@ -1305,7 +1333,6 @@ pub fn load<'a>(
|
||||||
Threads::Single => load_single_threaded(
|
Threads::Single => load_single_threaded(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
goal_phase,
|
goal_phase,
|
||||||
target_info,
|
target_info,
|
||||||
|
@ -1315,7 +1342,6 @@ pub fn load<'a>(
|
||||||
Threads::Many(threads) => load_multi_threaded(
|
Threads::Many(threads) => load_multi_threaded(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
goal_phase,
|
goal_phase,
|
||||||
target_info,
|
target_info,
|
||||||
|
@ -1331,7 +1357,6 @@ pub fn load<'a>(
|
||||||
pub fn load_single_threaded<'a>(
|
pub fn load_single_threaded<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
src_dir: &Path,
|
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
goal_phase: Phase,
|
goal_phase: Phase,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
|
@ -1343,6 +1368,7 @@ pub fn load_single_threaded<'a>(
|
||||||
ident_ids_by_module,
|
ident_ids_by_module,
|
||||||
root_id,
|
root_id,
|
||||||
root_msg,
|
root_msg,
|
||||||
|
src_dir,
|
||||||
..
|
..
|
||||||
} = load_start;
|
} = load_start;
|
||||||
|
|
||||||
|
@ -1394,7 +1420,7 @@ pub fn load_single_threaded<'a>(
|
||||||
stealers,
|
stealers,
|
||||||
&worker_msg_rx,
|
&worker_msg_rx,
|
||||||
&msg_tx,
|
&msg_tx,
|
||||||
src_dir,
|
&src_dir,
|
||||||
target_info,
|
target_info,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1532,7 +1558,6 @@ fn state_thread_step<'a>(
|
||||||
fn load_multi_threaded<'a>(
|
fn load_multi_threaded<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
src_dir: &Path,
|
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
goal_phase: Phase,
|
goal_phase: Phase,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
|
@ -1545,6 +1570,7 @@ fn load_multi_threaded<'a>(
|
||||||
ident_ids_by_module,
|
ident_ids_by_module,
|
||||||
root_id,
|
root_id,
|
||||||
root_msg,
|
root_msg,
|
||||||
|
src_dir,
|
||||||
..
|
..
|
||||||
} = load_start;
|
} = load_start;
|
||||||
|
|
||||||
|
@ -1622,8 +1648,9 @@ fn load_multi_threaded<'a>(
|
||||||
|
|
||||||
// We only want to move a *reference* to the main task queue's
|
// We only want to move a *reference* to the main task queue's
|
||||||
// injector in the thread, not the injector itself
|
// injector in the thread, not the injector itself
|
||||||
// (since other threads need to reference it too).
|
// (since other threads need to reference it too). Same with src_dir.
|
||||||
let injector = &injector;
|
let injector = &injector;
|
||||||
|
let src_dir = &src_dir;
|
||||||
|
|
||||||
// Record this thread's handle so the main thread can join it later.
|
// Record this thread's handle so the main thread can join it later.
|
||||||
let res_join_handle = thread_scope
|
let res_join_handle = thread_scope
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
interface Dep3.Blah
|
interface Dep3.Blah
|
||||||
exposes [one, two, foo, bar]
|
exposes [one, two, foo, bar]
|
||||||
imports []
|
imports [Dep3.Other]
|
||||||
|
|
||||||
one = 1
|
one = 1
|
||||||
|
|
||||||
two = 2
|
two = 2
|
||||||
|
|
||||||
foo = "foo from Dep3"
|
foo = "foo from Dep3"
|
||||||
bar = "bar from Dep3"
|
bar = Dep3.Other.bar
|
||||||
|
|
6
crates/compiler/load_internal/tests/fixtures/build/app_with_deps/Dep3/Other.roc
vendored
Normal file
6
crates/compiler/load_internal/tests/fixtures/build/app_with_deps/Dep3/Other.roc
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
interface Dep3.Other
|
||||||
|
exposes [foo, bar]
|
||||||
|
imports []
|
||||||
|
|
||||||
|
foo = "foo from Dep3.Other"
|
||||||
|
bar = "bar from Dep3.Other"
|
|
@ -30,23 +30,22 @@ use roc_target::TargetInfo;
|
||||||
use roc_types::pretty_print::name_and_print_var;
|
use roc_types::pretty_print::name_and_print_var;
|
||||||
use roc_types::pretty_print::DebugPrint;
|
use roc_types::pretty_print::DebugPrint;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn load_and_typecheck<'a>(
|
fn load_and_typecheck(
|
||||||
arena: &'a Bump,
|
arena: &Bump,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
src_dir: &Path,
|
src_dir: PathBuf,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
) -> Result<LoadedModule, LoadingProblem> {
|
||||||
use LoadResult::*;
|
use LoadResult::*;
|
||||||
|
|
||||||
let load_start = LoadStart::from_path(arena, filename, RenderTarget::Generic)?;
|
let load_start = LoadStart::from_path(arena, src_dir, filename, RenderTarget::Generic)?;
|
||||||
|
|
||||||
match roc_load_internal::file::load(
|
match roc_load_internal::file::load(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
src_dir,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
Phase::SolveTypes,
|
Phase::SolveTypes,
|
||||||
target_info,
|
target_info,
|
||||||
|
@ -167,7 +166,7 @@ fn multiple_modules_help<'a>(
|
||||||
load_and_typecheck(
|
load_and_typecheck(
|
||||||
arena,
|
arena,
|
||||||
full_file_path,
|
full_file_path,
|
||||||
dir.path(),
|
dir.path().to_path_buf(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
TARGET_INFO,
|
TARGET_INFO,
|
||||||
)
|
)
|
||||||
|
@ -184,13 +183,7 @@ fn load_fixture(
|
||||||
let src_dir = fixtures_dir().join(dir_name);
|
let src_dir = fixtures_dir().join(dir_name);
|
||||||
let filename = src_dir.join(format!("{}.roc", module_name));
|
let filename = src_dir.join(format!("{}.roc", module_name));
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
let loaded = load_and_typecheck(
|
let loaded = load_and_typecheck(&arena, filename, src_dir, subs_by_module, TARGET_INFO);
|
||||||
&arena,
|
|
||||||
filename,
|
|
||||||
src_dir.as_path(),
|
|
||||||
subs_by_module,
|
|
||||||
TARGET_INFO,
|
|
||||||
);
|
|
||||||
let mut loaded_module = match loaded {
|
let mut loaded_module = match loaded {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(roc_load_internal::file::LoadingProblem::FormattedReport(report)) => {
|
Err(roc_load_internal::file::LoadingProblem::FormattedReport(report)) => {
|
||||||
|
@ -346,13 +339,7 @@ fn interface_with_deps() {
|
||||||
let src_dir = fixtures_dir().join("interface_with_deps");
|
let src_dir = fixtures_dir().join("interface_with_deps");
|
||||||
let filename = src_dir.join("Primary.roc");
|
let filename = src_dir.join("Primary.roc");
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
let loaded = load_and_typecheck(
|
let loaded = load_and_typecheck(&arena, filename, src_dir, subs_by_module, TARGET_INFO);
|
||||||
&arena,
|
|
||||||
filename,
|
|
||||||
src_dir.as_path(),
|
|
||||||
subs_by_module,
|
|
||||||
TARGET_INFO,
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut loaded_module = loaded.expect("Test module failed to load");
|
let mut loaded_module = loaded.expect("Test module failed to load");
|
||||||
let home = loaded_module.module_id;
|
let home = loaded_module.module_id;
|
||||||
|
|
|
@ -98,7 +98,7 @@ mod solve_expr {
|
||||||
arena,
|
arena,
|
||||||
file_path,
|
file_path,
|
||||||
module_src,
|
module_src,
|
||||||
dir.path(),
|
dir.path().to_path_buf(),
|
||||||
exposed_types,
|
exposed_types,
|
||||||
roc_target::TargetInfo::default_x86_64(),
|
roc_target::TargetInfo::default_x86_64(),
|
||||||
roc_reporting::report::RenderTarget::Generic,
|
roc_reporting::report::RenderTarget::Generic,
|
||||||
|
@ -7324,4 +7324,21 @@ mod solve_expr {
|
||||||
"OList",
|
"OList",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rosetree_with_result_is_legal_recursive_type() {
|
||||||
|
infer_eq_without_problem(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
Rose a : [Rose (Result (List (Rose a)) I64)]
|
||||||
|
|
||||||
|
x : Rose I64
|
||||||
|
x = Rose (Ok [])
|
||||||
|
|
||||||
|
x
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
"Rose I64",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ where
|
||||||
&arena,
|
&arena,
|
||||||
encode_path().file_name().unwrap().into(),
|
encode_path().file_name().unwrap().into(),
|
||||||
source,
|
source,
|
||||||
encode_path().parent().unwrap(),
|
encode_path().parent().unwrap().to_path_buf(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
target_info,
|
target_info,
|
||||||
roc_reporting::report::RenderTarget::ColorTerminal,
|
roc_reporting::report::RenderTarget::ColorTerminal,
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
#[cfg(feature = "gen-llvm")]
|
#[cfg(feature = "gen-llvm")]
|
||||||
use crate::helpers::llvm::assert_evals_to;
|
use crate::helpers::llvm::assert_evals_to;
|
||||||
|
|
||||||
#[cfg(feature = "gen-dev")]
|
|
||||||
use crate::helpers::dev::assert_evals_to;
|
|
||||||
|
|
||||||
#[cfg(feature = "gen-wasm")]
|
#[cfg(feature = "gen-wasm")]
|
||||||
use crate::helpers::wasm::assert_evals_to;
|
use crate::helpers::wasm::assert_evals_to;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))]
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
|
||||||
#[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))]
|
#[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))]
|
||||||
|
|
|
@ -542,10 +542,7 @@ fn eq_different_rosetrees() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
#[ignore]
|
|
||||||
fn rosetree_with_tag() {
|
fn rosetree_with_tag() {
|
||||||
// currently stack overflows in type checking
|
|
||||||
|
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
|
|
|
@ -1622,7 +1622,6 @@ fn first_int_list() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
#[ignore]
|
|
||||||
fn first_wildcard_empty_list() {
|
fn first_wildcard_empty_list() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -1671,7 +1670,6 @@ fn last_int_list() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
#[ignore]
|
|
||||||
fn last_wildcard_empty_list() {
|
fn last_wildcard_empty_list() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
@ -1720,7 +1718,6 @@ fn get_empty_list() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
#[ignore]
|
|
||||||
fn get_wildcard_empty_list() {
|
fn get_wildcard_empty_list() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
|
|
@ -2464,7 +2464,6 @@ fn expanded_result() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
#[ignore]
|
|
||||||
fn backpassing_result() {
|
fn backpassing_result() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::helpers::wasm::{assert_evals_to, expect_runtime_error_panic};
|
||||||
// use crate::assert_wasm_evals_to as assert_evals_to;
|
// use crate::assert_wasm_evals_to as assert_evals_to;
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))]
|
||||||
use roc_std::{RocList, RocStr};
|
use roc_std::{RocList, RocStr};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1377,7 +1377,6 @@ fn str_to_nat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore = "TODO: figure out why returning i128 across FFI boundary is an issue"]
|
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn str_to_i128() {
|
fn str_to_i128() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
|
@ -1395,7 +1394,6 @@ fn str_to_i128() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore = "TODO: figure out why returning i128 across FFI boundary is an issue"]
|
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn str_to_u128() {
|
fn str_to_u128() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
|
@ -1569,7 +1567,6 @@ fn str_to_f32() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore = "TODO: figure out why returning i128 across FFI boundary is an issue"]
|
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn str_to_dec() {
|
fn str_to_dec() {
|
||||||
use roc_std::RocDec;
|
use roc_std::RocDec;
|
||||||
|
|
|
@ -9,7 +9,8 @@ use crate::helpers::wasm::assert_evals_to;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
#[cfg(test)]
|
|
||||||
|
#[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))]
|
||||||
use roc_std::{RocList, RocStr};
|
use roc_std::{RocList, RocStr};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -532,14 +533,12 @@ fn if_guard_vanilla() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
#[ignore]
|
|
||||||
fn when_on_single_value_tag() {
|
fn when_on_single_value_tag() {
|
||||||
// this fails because the switched-on symbol is not defined
|
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
when Identity 0 is
|
when Identity 0 is
|
||||||
Identity 0 -> 0
|
Identity 0 -> 6
|
||||||
Identity s -> s
|
Identity s -> s
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
|
@ -1046,9 +1045,7 @@ fn alignment_in_multi_tag_pattern_match() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
#[ignore]
|
|
||||||
fn phantom_polymorphic() {
|
fn phantom_polymorphic() {
|
||||||
// see https://github.com/rtfeldman/roc/issues/786 and below
|
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r"#
|
r"#
|
||||||
|
@ -1072,11 +1069,7 @@ fn phantom_polymorphic() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
#[ignore]
|
|
||||||
fn phantom_polymorphic_record() {
|
fn phantom_polymorphic_record() {
|
||||||
// see https://github.com/rtfeldman/roc/issues/786
|
|
||||||
// also seemed to hit an issue where we check whether `add`
|
|
||||||
// has a Closure layout while the type is not fully specialized yet
|
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
use libloading::Library;
|
use libloading::Library;
|
||||||
use roc_build::link::{link, LinkType};
|
use roc_build::link::{link, LinkType};
|
||||||
use roc_builtins::bitcode;
|
use roc_builtins::bitcode;
|
||||||
use roc_collections::all::MutMap;
|
|
||||||
use roc_load::Threading;
|
use roc_load::Threading;
|
||||||
use roc_region::all::LineInfo;
|
use roc_region::all::LineInfo;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
|
use roc_collections::all::MutMap;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use roc_mono::ir::pretty_print_ir_symbols;
|
use roc_mono::ir::pretty_print_ir_symbols;
|
||||||
|
|
||||||
|
@ -30,11 +32,11 @@ pub fn helper(
|
||||||
_leak: bool,
|
_leak: bool,
|
||||||
lazy_literals: bool,
|
lazy_literals: bool,
|
||||||
) -> (String, Vec<roc_problem::can::Problem>, Library) {
|
) -> (String, Vec<roc_problem::can::Problem>, Library) {
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
let filename = PathBuf::from("Test.roc");
|
let filename = PathBuf::from("Test.roc");
|
||||||
let src_dir = Path::new("fake/test/path");
|
let src_dir = PathBuf::from("fake/test/path");
|
||||||
let app_o_file = dir.path().join("app.o");
|
let app_o_file = dir.path().join("app.o");
|
||||||
|
|
||||||
let module_src;
|
let module_src;
|
||||||
|
|
|
@ -50,12 +50,10 @@ fn create_llvm_module<'a>(
|
||||||
context: &'a inkwell::context::Context,
|
context: &'a inkwell::context::Context,
|
||||||
target: &Triple,
|
target: &Triple,
|
||||||
) -> (&'static str, String, &'a Module<'a>) {
|
) -> (&'static str, String, &'a Module<'a>) {
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
let target_info = roc_target::TargetInfo::from(target);
|
let target_info = roc_target::TargetInfo::from(target);
|
||||||
|
|
||||||
let filename = PathBuf::from("Test.roc");
|
let filename = PathBuf::from("Test.roc");
|
||||||
let src_dir = Path::new("fake/test/path");
|
let src_dir = PathBuf::from("fake/test/path");
|
||||||
|
|
||||||
let module_src;
|
let module_src;
|
||||||
let temp;
|
let temp;
|
||||||
|
|
|
@ -69,7 +69,7 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
|
||||||
_test_wrapper_type_info: PhantomData<T>,
|
_test_wrapper_type_info: PhantomData<T>,
|
||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
let filename = PathBuf::from("Test.roc");
|
let filename = PathBuf::from("Test.roc");
|
||||||
let src_dir = Path::new("fake/test/path");
|
let src_dir = PathBuf::from("fake/test/path");
|
||||||
|
|
||||||
let module_src;
|
let module_src;
|
||||||
let temp;
|
let temp;
|
||||||
|
|
|
@ -73,12 +73,12 @@ fn promote_expr_to_module(src: &str) -> String {
|
||||||
|
|
||||||
fn compiles_to_ir(test_name: &str, src: &str) {
|
fn compiles_to_ir(test_name: &str, src: &str) {
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
let arena = &Bump::new();
|
let arena = &Bump::new();
|
||||||
|
|
||||||
let filename = PathBuf::from("Test.roc");
|
let filename = PathBuf::from("Test.roc");
|
||||||
let src_dir = Path::new("fake/test/path");
|
let src_dir = PathBuf::from("fake/test/path");
|
||||||
|
|
||||||
let module_src;
|
let module_src;
|
||||||
let temp;
|
let temp;
|
||||||
|
|
|
@ -1482,6 +1482,8 @@ impl Type {
|
||||||
Type::Apply(Symbol::LIST_LIST | Symbol::SET_SET, _, _) => false,
|
Type::Apply(Symbol::LIST_LIST | Symbol::SET_SET, _, _) => false,
|
||||||
Type::Apply(..) => internal_error!("cannot chase an Apply!"),
|
Type::Apply(..) => internal_error!("cannot chase an Apply!"),
|
||||||
Type::Alias { .. } => internal_error!("should be dealiased"),
|
Type::Alias { .. } => internal_error!("should be dealiased"),
|
||||||
|
// Must be conservative here because we don't know what the alias expands to yet
|
||||||
|
Type::DelayedAlias(..) => false,
|
||||||
// Non-composite types are trivially narrow
|
// Non-composite types are trivially narrow
|
||||||
_ => true,
|
_ => true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -438,7 +438,7 @@ pub fn load_modules_for_files(filenames: Vec<PathBuf>) -> Vec<LoadedModule> {
|
||||||
match roc_load::load_and_typecheck(
|
match roc_load::load_and_typecheck(
|
||||||
&arena,
|
&arena,
|
||||||
filename,
|
filename,
|
||||||
src_dir.as_path(),
|
src_dir,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
roc_target::TargetInfo::default_x86_64(), // This is just type-checking for docs, so "target" doesn't matter
|
roc_target::TargetInfo::default_x86_64(), // This is just type-checking for docs, so "target" doesn't matter
|
||||||
roc_reporting::report::RenderTarget::ColorTerminal,
|
roc_reporting::report::RenderTarget::ColorTerminal,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_load::Threading;
|
use roc_load::Threading;
|
||||||
use roc_reporting::report::Palette;
|
use roc_reporting::report::Palette;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use roc_fmt::annotation::Formattable;
|
use roc_fmt::annotation::Formattable;
|
||||||
use roc_fmt::annotation::{Newlines, Parens};
|
use roc_fmt::annotation::{Newlines, Parens};
|
||||||
|
@ -49,7 +49,7 @@ pub fn compile_to_mono<'a>(
|
||||||
palette: Palette,
|
palette: Palette,
|
||||||
) -> Result<MonomorphizedModule<'a>, Vec<String>> {
|
) -> Result<MonomorphizedModule<'a>, Vec<String>> {
|
||||||
let filename = PathBuf::from("");
|
let filename = PathBuf::from("");
|
||||||
let src_dir = Path::new("fake/test/path");
|
let src_dir = PathBuf::from("fake/test/path");
|
||||||
|
|
||||||
let module_src = arena.alloc(promote_expr_to_module(src));
|
let module_src = arena.alloc(promote_expr_to_module(src));
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ mod test_reporting {
|
||||||
let result = roc_load::load_and_typecheck(
|
let result = roc_load::load_and_typecheck(
|
||||||
arena,
|
arena,
|
||||||
full_file_path,
|
full_file_path,
|
||||||
dir.path(),
|
dir.path().to_path_buf(),
|
||||||
exposed_types,
|
exposed_types,
|
||||||
roc_target::TargetInfo::default_x86_64(),
|
roc_target::TargetInfo::default_x86_64(),
|
||||||
RenderTarget::Generic,
|
RenderTarget::Generic,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue