tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Types: warn on module-shadowing locals and unused imports (issue #297)

Two import-ergonomics diagnostics, both rooted in name resolution:

- W0101: a local binding (parameter, let, match or lambda binding)
  named like an imported module shadows it. `list.length` then reads
  a field of the local, not an item of `std/list`, and the failure
  surfaced as a bare "several constructors" field error. The binding
  now warns where the local is introduced, and the field error such an
  access fails with (E0203/E0206, also E0117/E0215) gains a secondary
  label at the binding and a note naming the module it shadows. The
  shadow is recognised in inference, on the error path only, from a
  `Expr::Local` base whose name is an imported module alias.

- W0102: an import nothing uses. Lowering records every resolved
  import (Hir::imports) and what resolution went through it
  (ImportUse: qualified `m.item` accesses by module pair, and defs
  referred to by name, per module). After lowering, an import with no
  qualified access and no used item warns. Used counts type-only and
  effect-row-only uses, pattern and component qualifiers, and items
  used by name; traits and derive functions named by
  @derive/@derivable resolve in the type checker, so a post-pass
  counts them. Two aliases of one module cannot be told apart: using
  one marks both. The prelude needs no import and is never linted.

std itself had three unused imports (std/time's std/list, std/http/sse's
std/option and std/ffi.{type Resource}); removed.

olivier · il y a 1 mois · 3c73d155ba4c2c24bf5dfeb69745953ebcfd289d

Parents 4d894e2

12 fichiers modifiés, 323 ajouts, 42 suppressions