Saltar al contenido
TE105 · Tipos · error

Módulo de la stdlib usado sin `use std::…`

Un nombre simple corresponde a un módulo conocido de la biblioteca estándar (`math`, `json`, `http`, `os`, …) que nunca se trajo al ámbito. A diferencia de TE100, el compilador reconoce el nombre e indica exactamente qué línea `use` falta.

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.

Véase también

Buscar en Zolo

9 resultados

en