Merge pull request #6361 from faldor20/fix-lang-server-hang

Fix hang from bad imports
This commit is contained in:
Richard Feldman 2024-01-21 22:06:48 -05:00 committed by GitHub
commit 07ddd272e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 127 additions and 8 deletions

View file

@ -1058,7 +1058,6 @@ fn module_cyclic_import_itself() {
err
);
}
#[test]
fn module_cyclic_import_transitive() {
let modules = vec![
@ -1148,3 +1147,55 @@ fn nested_module_has_incorrect_name() {
err
);
}
#[test]
fn module_interface_with_qualified_import() {
let modules = vec![(
"A",
indoc!(
r"
interface A exposes [] imports [b.T]
"
),
)];
let err = multiple_modules("module_interface_with_qualified_import", modules).unwrap_err();
assert_eq!(
err,
indoc!(
r#"
The package shorthand 'b' that you are using in the 'imports' section of the header of module 'tmp/module_interface_with_qualified_import/A' doesn't exist.
Check that package shorthand is correct or reference the package in an 'app' or 'package' header.
This module is an interface, because of a bug in the compiler we are unable to directly typecheck interface modules with package imports so this error may not be correct. Please start checking at an app, package or platform file that imports this file."#
),
"\n{}",
err
);
}
#[test]
fn app_missing_package_import() {
let modules = vec![(
"Main",
indoc!(
r#"
app "example"
packages { pack: "./package/main.roc" }
imports [notpack.Mod]
provides [] to pack
main = ""
"#
),
)];
let err = multiple_modules("app_missing_package_import", modules).unwrap_err();
assert_eq!(
err,
indoc!(
r#"
The package shorthand 'notpack' that you are using in the 'imports' section of the header of module 'tmp/app_missing_package_import/Main' doesn't exist.
Check that package shorthand is correct or reference the package in an 'app' or 'package' header."#
),
"\n{}",
err
);
}