···363363364364 let module_name = format!("${module_name}");
365365 let path = self.import_path(package, module);
366366- let unqualified_imports = unqualified
367367- .iter()
368368- // We do not create a JS import for types as they are not used at runtime
369369- .filter(|import| {
370370- !self
371371- .module
372372- .type_info
373373- .type_only_unqualified_imports
374374- .contains(&import.name)
375375- })
376376- .map(|i| {
377377- let alias = i.as_name.as_ref().map(|n| {
378378- self.register_in_scope(n);
379379- maybe_escape_identifier_doc(n)
380380- });
381381- let name = maybe_escape_identifier_doc(&i.name);
382382- Member { name, alias }
366366+ let unqualified_imports = unqualified.iter().map(|i| {
367367+ let alias = i.as_name.as_ref().map(|n| {
368368+ self.register_in_scope(n);
369369+ maybe_escape_identifier_doc(n)
383370 });
371371+ let name = maybe_escape_identifier_doc(&i.name);
372372+ Member { name, alias }
373373+ });
384374385375 let aliases = if discarded { vec![] } else { vec![module_name] };
386376 imports.register_module(path, aliases, unqualified_imports);
···16961696 })?;
1697169716981698 // Register the value as seen for detection of unused values
16991699- self.environment.increment_usage(name, Layer::Value);
16991699+ self.environment.increment_usage(name);
1700170017011701 constructor
17021702 }
+1-1
compiler-core/src/type_/hydrator.rs
···143143 // We do not track use of qualified type constructors as they may be
144144 // used in another module.
145145 if module.is_none() {
146146- environment.increment_usage(name, Layer::Type);
146146+ environment.increment_usage(name);
147147 }
148148149149 // Ensure that the correct number of arguments have been given to the constructor
+2-2
compiler-core/src/type_/pattern.rs
···233233 name: name.clone(),
234234 variables: self.environment.local_value_names(),
235235 })?;
236236- self.environment.increment_usage(&name, Layer::Value);
236236+ self.environment.increment_usage(&name);
237237 let typ =
238238 self.environment
239239 .instantiate(vc.type_.clone(), &mut hashmap![], self.hydrator);
···411411 ..
412412 } => {
413413 // Register the value as seen for detection of unused values
414414- self.environment.increment_usage(&name, Layer::Value);
414414+ self.environment.increment_usage(&name);
415415416416 let cons = self
417417 .environment
···33assertion_line: 175
44expression: "import one.{Two}\n\npub fn main() {\n Two\n}"
55---
66-error: Unknown variable
77- ┌─ /src/one/two.gleam:4:3
66+error: Unknown module field
77+ ┌─ /src/one/two.gleam:1:13
88 │
99-4 │ Two
1010- │ ^^^ Did you mean `Nil`?
99+1 │ import one.{Two}
1010+ │ ^^^
11111212-The name `Two` is not in scope here.
1212+The module `one` does not have a `Two` value.
1313
-44
compiler-core/src/type_/tests/warnings.rs
···10741074}
1075107510761076#[test]
10771077-fn deprecate_type_import_extenal() {
10781078- assert_warning!(
10791079- ("package", "module", "pub type X"),
10801080- "
10811081-import module.{X}
10821082-pub type Y = X
10831083-"
10841084- );
10851085-}
10861086-10871087-#[test]
10881088-fn deprecate_type_import_type_alias() {
10891089- assert_warning!(
10901090- ("package", "module", "pub type X = Int"),
10911091- "
10921092-import module.{X}
10931093-pub type Y = X
10941094-"
10951095- );
10961096-}
10971097-10981098-#[test]
10991099-fn deprecate_type_import_type_custom_type() {
11001100- assert_warning!(
11011101- ("package", "module", "pub type X { X }"),
11021102- "
11031103-import module.{X}
11041104-pub type Y = X
11051105-"
11061106- );
11071107-}
11081108-11091109-#[test]
11101110-fn deprecate_type_import_type_custom_type_not_using_type() {
11111111- assert_no_warnings!(
11121112- ("package", "module", "pub type X { X }"),
11131113- "
11141114-import module.{X}
11151115-pub const x = X
11161116-"
11171117- );
11181118-}
11191119-11201120-#[test]
11211077fn unused_module_wuth_alias_warning_test() {
11221078 assert_warning!(
11231079 ("gleam/foo", "pub const one = 1"),
-24
compiler-core/src/warning.rs
···613613 }
614614 }
615615616616- type_::Warning::DeprecatedTypeImport { name, location } => {
617617- let text = wrap(&format!(
618618- "The syntax for importing a type has changed. The new syntax is:
619619-620620- import module.{{type {name}}}
621621-"
622622- ));
623623- Diagnostic {
624624- title: "Deprecated type import".into(),
625625- text,
626626- hint: Some("Run `gleam fix` to auto-fix your code.".into()),
627627- level: diagnostic::Level::Warning,
628628- location: Some(Location {
629629- src: src.clone(),
630630- path: path.to_path_buf(),
631631- label: diagnostic::Label {
632632- text: None,
633633- span: *location,
634634- },
635635- extra_labels: Vec::new(),
636636- }),
637637- }
638638- }
639639-640616 type_::Warning::InexhaustiveLetAssignment { location, missing } => {
641617 let mut text: String =
642618 "This assignment uses a pattern that does not match all possible
···11-import one.{User}
11+import one.{type User}
2233// This operation is not permitted because the type is opaque and this module
44// did not define the custom type.
···11-pub opaque type User {
22- User(name: String, score: Int)
33-}
44-55-// These operations are permitted in this module as it is the one that defined
66-// the custom type
77-88-pub fn construct() {
99- User(name: "Alim", score: 10)
1010-}
1111-1212-pub fn accessors(user: User) {
1313- let name = user.name
1414- let score = user.score
1515- #(name, score)
1616-}
1717-1818-pub fn destructure(user: User) {
1919- let User(name: name, score: score) = user
2020- #(name, score)
2121-}
···11-import one.{User}
22-33-// This operation is not permitted because the type is opaque and this module
44-// did not define the custom type.
55-66-pub fn construct() {
77- User(name: "Alim", score: 10)
88-}
···11-import one.{User}
11+import one
2233// This operation is not permitted because the type is opaque and this module
44// did not define the custom type.
5566-pub fn destructure(user: User) {
77- let User(name: name, score: score) = user
66+pub fn destructure(user: one.User) {
77+ let one.User(name: name, score: score) = user
88 #(name, score)
99}
···11---
22source: test-package-compiler/src/generated_tests.rs
33-assertion_line: 261
33+assertion_line: 249
44expression: "./cases/opaque_type_destructure"
55---
66-error: Unknown variable
66+error: Unknown module field
77 ┌─ src/two.gleam:7:7
88 │
99-7 │ let User(name: name, score: score) = user
1010- │ ^ Did you mean `user`?
99+7 │ let one.User(name: name, score: score) = user
1010+ │ ^ Did you mean `accessors`?
11111212-The name `User` is not in scope here.
1212+The module `one` does not have a `User` value.
1313