Error codes · Names and imports

PW0021

unresolved_name

The program must hold to this: an imported name must be declared by the module it comes from.

A program the compiler refuses with it

Refused: PW0021
module count

fn count(names: List<String>) -> Int !{} {
    List.length(names)
}
pw check
error: [PW0021] `List.length` does not resolve
 --> count.pw:4:5
  |
3 | / fn count(names: List<String>) -> Int !{} {
4 | |     List.length(names)
  | |     ^^^^^^^^^^^^^^^^^^ `List.length` does not resolve
5 | | }
  | |_- used inside `count`
  |
  = note: `List` is not a module this file can see. Names are visible through lexical scope, module membership, or an explicit import — external implementation is allowed, a missing declaration is not.
  = help: add `import List`, or declare it

From A module's functions, used without importing it, in Errors and diagnostics. A test holds the guide's examples to the compiler.

Reading the diagnostic

pw check prints the code in brackets, [PW0021], with the sentence above and the place in your program. Errors and diagnostics explains how to read one, and every code is listed with its rule.