// Import ergonomics (issue #297): a local named like an imported module // shadows it (W0101) and the failing `local.item` access says so, and an // import nothing uses is drift (W0102). import std/dict as d import std/http/cookie //~ WARN W0102 never used import std/io import std/list import std/option.{is_some} import std/random //~ WARN W0102 never used import std/string.{repeat} //~ WARN W0102 never used import std/time // A parameter named like an imported module shadows it; the field access // that follows fails, with a note pointing at the parameter. fn total :: list: List //~ WARN W0101 shadows the imported module -> Int { list.length list //~ ERROR E0206 several constructors } // Shadowing warns even without a qualified access. fn head_or_zero :: list: List -> Int //~^ WARN W0101 shadows the imported module { match list { [] -> 0, [x, ..] -> x } } // A local whose name no import bears shadows nothing; an import renamed // with `as` binds only its alias (`d`, not `dict`). fn describe :: server: String dict: d.Dict -> String { server } // A module used only in types and effect rows is used. fn with_clock :: f: fn() -> Int / -> Int / { f () } // An item imported by name and used by name: the import is used. fn present :: x: Option -> Bool { is_some x } // The prelude needs no import. fn shown :: -> String { show 1 } pub fn main :: -> () / { io.println (show (total (list.range 1 3))) }