Home / Docs / Diagnostics

U1010: A module whose first path segment is a dependency's local name

Release v0.4.0

From edition 0.4, a package's modules import a dependency's modules under the dependency's local name: the module text of the dependency util is util.text in the importing package (ADR 0122 rule 47, spec/30). A module of the package whose path starts with that local name could be mistaken for one of the dependency's, so it is U1010 at its header. The repair is to give the need another local name with as, or to rename the module.

The repair at a glance

ita.unadiff
  ita demo
    version 0.1.0
    edition 0.4

  needs
-   util from path "deps/util"
+   util as strings from path "deps/util"
      accept name
src/util.unadiff
  module util

- import util.text (shout)
+ import strings.text (shout)

  pub greet() -> Text = shout("hello")

Failing example

ita.unauna
ita demo
  version 0.1.0
  edition 0.4

needs
  util from path "deps/util"
    accept name
ita.lockuna
lock 1

solver
  encoding "una-smt-1"
  name "z3"
  version "5.1.0"
  logic "QF_UFLIA"
  steps 5000000
  seed 0

package util 0.1.0
  from path "deps/util"
  digest "sha256:0000000000000000000000000000000000000000000000000000000000000000"
deps/util/ita.unauna
ita util
  version 0.1.0
  edition 0.4
deps/util/src/text.unauna
module text

pub shout(word: Text) -> Text = word
src/util.unauna
module util

import util.text (shout)

pub greet() -> Text = shout("hello")

Fixed example

ita.unauna
ita demo
  version 0.1.0
  edition 0.4

needs
  util as strings from path "deps/util"
    accept name
ita.lockuna
lock 1

solver
  encoding "una-smt-1"
  name "z3"
  version "5.1.0"
  logic "QF_UFLIA"
  steps 5000000
  seed 0

package util 0.1.0
  from path "deps/util"
  digest "sha256:0000000000000000000000000000000000000000000000000000000000000000"
deps/util/ita.unauna
ita util
  version 0.1.0
  edition 0.4
deps/util/src/text.unauna
module text

pub shout(word: Text) -> Text = word
src/util.unauna
module util

import strings.text (shout)

pub greet() -> Text = shout("hello")