Pular para o conteúdo
TE105 · Tipos · error

Módulo da stdlib usado sem `use std::…`

Um nome simples corresponde a um módulo conhecido da biblioteca padrão (`math`, `json`, `http`, `os`, …) que nunca foi trazido ao escopo. Diferente do TE100, o compilador reconhece o nome e diz exatamente qual linha `use` está faltando.

Why this fires

A bare name matches a known standard-library module (math, json, http, os, ...), but the module was never brought into scope with use std::<name> (or use std::*). Referencing an un-imported module by name is not the same mistake as referencing a truly undefined variable (TE100) — Zolo recognizes the name and tells you exactly which use line is missing.

let result = math.sqrt(4.0)
//           ^^^^ error[TE105]: `math` requires `use std::math` (or `use std::*`)

Fix it

Add the missing import:

use std::math

let result = math.sqrt(4.0)     // ok

TE105 also fires on near-misses — a typo that is one edit away from a real module name:

let x = jsom.stringify(#{ a: 1 })
//      ^^^^ error[TE105]: `jsom` is not a known name. Did you mean the stdlib module `json` (`use std::json`)?

Fix the spelling and add the import:

use std::json

let x = json.stringify(#{ a: 1 })  // ok

See also

  • TE100 — undefined variable (a name with no relation to any stdlib module).
  • /docs/modulesuse and the standard library layout.

Veja também

Buscar no Zolo

9 resultados

en