Report unrecognized shorthands when loading from the root module

This commit is contained in:
Agus Zubiaga 2024-06-08 14:12:01 -03:00
parent 5a1bf2b891
commit 7faff12cbf
No known key found for this signature in database
7 changed files with 245 additions and 29 deletions

View file

@ -2,6 +2,7 @@ platform "test-platform"
requires {} { main : * }
exposes []
packages {}
imports []
provides [mainForHost]
mainForHost : {} -> {}

View file

@ -11670,6 +11670,54 @@ In roc, functions are always written as a lambda, like{}
@r"
"
);
test_report!(
unknown_shorthand_no_deps,
indoc!(
r#"
import foo.Foo
Foo.foo
"#
),
@r###"
UNKNOWN PACKAGE in tmp/unknown_shorthand_no_deps/Test.roc
This module is trying to import from `foo`:
4 import foo.Foo
^^^^^^^
A lowercase name indicates a package shorthand, but no packages have
been specified.
"###
);
test_report!(
unknown_shorthand_in_app,
indoc!(
r#"
app [main] { pf: platform "../../tests/platform.roc" }
import foo.Foo
main =
Foo.foo
"#
),
@r###"
UNKNOWN PACKAGE in tmp/unknown_shorthand_in_app/Test.roc
This module is trying to import from `foo`:
3 import foo.Foo
^^^^^^^
A lowercase name indicates a package shorthand, but I don't recognize
this one. Did you mean one of these?
pf
"###
);
test_report!(
invalid_toplevel_cycle,