Type Error¶
A detected mismatch between a program term's assigned or inferred type and the type required by the operation or context in which the term is used.
Core Idea¶
A type error is a failed compatibility judgment. A type system assigns or infers a type for a program term, the surrounding expression or operation demands another type, and the language's rules do not permit the term in that position. The error is therefore relational: an integer is not erroneous by itself, but can be incompatible with a context requiring a function or string.
Detection can occur during static analysis or on an executed path at runtime. What counts as compatible depends on the language's rules for equality, subtyping, polymorphism, coercion, inference, and gradual types. Type checking excludes a defined class of invalid interpretations; it does not prove that the algorithm, value range, memory behavior, or business intent is otherwise correct.
Scope of Application¶
- Compilation. Static checkers reject incompatible expressions before code executes.
- Dynamic execution. Runtime tags and checks detect mismatches on actual paths.
- Generic programming. Polymorphic constraints determine whether type arguments and operations align.
- Gradual typing. Typed and untyped regions exchange values through explicit or inserted checks.
Clarity¶
Report the term, inferred or runtime type, expected type, compatibility rule, source location, and checking phase. Compiler wording may point at a downstream constraint rather than the originating declaration, so diagnostic analysis should reconstruct the type derivation. Avoid calling any bad value a type error when its type was accepted. Inclusion test: A positive case derives or observes an actual type for a term, an expected type from its context, and a language rule declaring them incompatible. Exclusion test: A syntactic parse failure occurs before typing and is not a type error. Nearest boundary: A value of an accepted type that nevertheless causes a domain error, such as division by zero, is a runtime validity error rather than necessarily a type error. Exit condition: The case exits when the language permits the use through subtyping, coercion, gradual typing, or an explicit dynamic check. Common misclassifications: It is not a syntax error that prevents the program from being parsed. It is not every runtime exception or wrong program result. It is not intrinsic to a value independent of the context and language type rules. It is not proof that a whole language is type-unsafe; safe systems can report type errors as intended. Nearest named distinctions: Syntax error: Violates grammatical formation before type compatibility is judged. Domain error: Uses a well-typed value outside an operation's valid numeric or semantic range. Type unsafety: A language property concerning whether type guarantees prevent certain runtime failures. Logic error: Produces unintended behavior while remaining syntactically and type-correct.
Manages Complexity¶
Types compress sets of possible values and operations into names or structural descriptions. A checker can thereby eliminate entire bug classes without executing every path. That compression is necessarily selective: refinements, effects, dependent types, and runtime contracts move additional properties into or out of the type boundary.
Abstract Reasoning¶
- Identify the smallest term whose use is rejected or dynamically fails.
- Derive its actual type under the language's environment and inference rules.
- Derive the type expected by the enclosing operation or context.
- Apply equality, subtyping, coercion, and polymorphic constraints in the correct variance positions.
- Locate when the incompatibility is checked and whether only one runtime path is affected.
- Repair the program or declaration without masking a real semantic mismatch through unsafe conversion.
Knowledge Transfer¶
Type-error reasoning transfers across programming languages only after substituting each language's type and compatibility rules. A category mistake in prose or a schema-validation failure can be analogous but is not literally a programming-language type error. The transferable cargo is actual-type versus required-type incompatibility; the checker phase and admissible conversions remain language-specific.
Neighborhood in Abstraction Space¶
Type Error sits in a crowded region of the domain-specific corpus (28th percentile for distinctiveness): several abstractions share nearly its structure, so a description that fits it tends to fit its neighbors too.
Family — Organizational Patterns & Management Concepts (29 abstractions)
Nearest neighbors
- Bare Nouns — 0.90
- Word-Learning Biases — 0.90
- Let-Polymorphism — 0.89
- Verifiable Computing — 0.89
- Generalized Büchi Automaton — 0.88
Computed from structural-signature embeddings · 2026-10-08