mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-17 17:25:01 +00:00
Merge pull request #7412 from gamebox/issue-7407
#7407: Register package dependent packages
This commit is contained in:
commit
b0d1d16db6
2 changed files with 62 additions and 3 deletions
|
@ -1317,8 +1317,13 @@ fn handle_root_type<'a>(
|
|||
|
||||
use HeaderType::*;
|
||||
|
||||
let use_main = match header_type {
|
||||
Package { .. } | App { .. } | Platform { .. } => true,
|
||||
Module { .. } | Builtin { .. } | Hosted { .. } => false,
|
||||
};
|
||||
|
||||
match header_type {
|
||||
Module { .. } | Builtin { .. } | Hosted { .. } => {
|
||||
Module { .. } | Builtin { .. } | Hosted { .. } | Package { .. } => {
|
||||
let main_path = opt_main_path.or_else(|| find_main_roc_recursively(src_dir));
|
||||
|
||||
let cache_dir = roc_cache_dir.as_persistent_path();
|
||||
|
@ -1340,9 +1345,15 @@ fn handle_root_type<'a>(
|
|||
header_output.msg = Msg::Many(messages);
|
||||
}
|
||||
|
||||
Ok((header_output, RootType::Module { main_path }))
|
||||
let root_type = if use_main {
|
||||
RootType::Main
|
||||
} else {
|
||||
RootType::Module { main_path }
|
||||
};
|
||||
|
||||
Ok((header_output, root_type))
|
||||
}
|
||||
App { .. } | Package { .. } | Platform { .. } => Ok((header_output, RootType::Main)),
|
||||
App { .. } | Platform { .. } => Ok((header_output, RootType::Main)),
|
||||
}
|
||||
} else {
|
||||
Ok((header_output, RootType::Main))
|
||||
|
|
|
@ -2131,3 +2131,51 @@ fn roc_file_no_extension() {
|
|||
|
||||
assert_eq!(err, expected, "\n{}", err);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn roc_package_depends_on_other_package() {
|
||||
let modules = vec![
|
||||
(
|
||||
"main",
|
||||
indoc!(
|
||||
r#"
|
||||
package [Module] { other: "other/main.roc" }
|
||||
"#
|
||||
),
|
||||
),
|
||||
(
|
||||
"Module.roc",
|
||||
indoc!(
|
||||
r#"
|
||||
module [foo]
|
||||
|
||||
import other.OtherMod
|
||||
|
||||
foo = OtherMod.say "hello"
|
||||
"#
|
||||
),
|
||||
),
|
||||
(
|
||||
"other/main.roc",
|
||||
indoc!(
|
||||
r#"
|
||||
package [OtherMod] {}
|
||||
"#
|
||||
),
|
||||
),
|
||||
(
|
||||
"other/OtherMod.roc",
|
||||
indoc!(
|
||||
r#"
|
||||
module [say]
|
||||
|
||||
say = \msg -> "$(msg), world!"
|
||||
"#
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
let result = multiple_modules("roc_package_depends_on_other_package", modules);
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue