On this page
Names, declarations and type errors
Name and type diagnostics often have a local source location but a project-wide cause. Check source selection, visibility and the declared profile before rewriting the expression that the compiler rejected. The shared program structure and types chapters define the underlying rules.
Find the declaration you intended
B1001 means no declaration is visible at that use. Confirm spelling, scope, package qualification and context imports. A similarly spelled suggestion may identify a real name without making it the right abstraction. B1003 instead means the loader could not locate a referenced unit; check project source directories and filename conventions before adding another local declaration.
The compiler finds the units a program imports, and their bodies, in the directory of the files you name and in a project's source-dirs; a unit it cannot find is B1003. In Vibe, from m import f makes only f visible, so another name of m used unqualified is B1001: import it too, or import m and write m.g. See projects and Vibe names.
If a name exists but has the wrong kind, B1004 can identify a package used as a value or a type used where an object is required. Do not treat this as a missing import without reading the declaration. Overload ambiguity and invisible operators require enough type context or the correct visibility, rather than an arbitrary rename.
For missing or nonconforming completions, compare the specification and body, including parameter modes, types, result, names where required and package placement. A declaration in another scope does not necessarily complete the original declaration. Check the subprogram reference and syntax-specific unit rules.
Separate type identity from constraints
A derived numeric type has distinct type identity; a subtype restricts values of an existing type. An explicit conversion can bridge supported identities, but it may introduce a proof obligation that the value fits the destination. Adding a cast merely moves the question if the value remains invalid.
| Diagnostic | Typical distinction | Repair to assess |
|---|---|---|
| B2001 type mismatch | Expression type differs from required type. | Use the intended declaration or a justified supported conversion. |
| B2002 static value outside range | An invalid value is known before proof. | Correct the literal, subtype or declared requirement. |
| B2003 nonstatic expression | The context requires compile-time information. | Supply a static declaration or choose a dynamic context. |
| B2005 wrong arguments | Count, mode, names or profile do not match. | Compare the actual supported callable profile. |
| B2006 unknown component | The selected field is not in this visible view. | Check visibility, discriminants and record type. |
| B2007 unknown attribute | The type has no such attribute. | Consult the attribute table in the Language Reference. |
| B2010 invalid aggregate | Shape, fields, alternatives or expected type do not agree. | Give complete components with the right target context. |
| B2014 limited copy | A resource value cannot be freely copied. | Move, borrow or redesign the interface according to ownership rules. |
For arrays, length and lower bounds are separate facts. A shape-compatible assignment can slide bounds, while indexing still uses each actual dimension's range. For constrained records, fields can depend on discriminants. Inspect actual values and expected type rather than assuming that equal storage size makes two composites interchangeable.
Keep static rejection separate from proof
Some errors are rejected while lowering; others produce runtime-check obligations for proof. A literal outside its declared range can report B2002, while a dynamic assignment to a narrower subtype can produce B4102. A failed arithmetic base-range check is B4101. The integer reference gives boundary examples in all three syntaxes. Preserve these distinctions when designing an automated report or reviewing a fix.
After a type repair, check the public behavior. Widening a result, making a type nullable or weakening a discriminant can change the accepted state space. Update callers and contracts, and prove that the new representation still enforces the original application requirement.