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.
Structural Signature¶
Sig role-phrases:
- program term — supplies the expression, value, function, variable, or module being classified It is essential. Counterfactual: Without a term there is no typed use to judge.
- assigned or inferred type — summarizes the term's permitted values and operations It is essential. Counterfactual: An untyped term cannot violate the type system's compatibility relation.
- use context — imposes an expected argument, result, field, or control-condition type It is essential. Counterfactual: A type becomes erroneous only relative to a context's requirement.
- compatibility rule — decides whether the actual type may be used where the expected type is required It is essential. Counterfactual: Nominal, structural, subtype, and coercion rules can classify the same syntax differently.
- checking phase — determines whether the mismatch is rejected before execution or detected during it It is essential. Counterfactual: Conflating static and dynamic checks misstates when and for which runs the error arises.
- diagnostic — identifies the conflicting types and relevant source location or execution path It is characteristic. Counterfactual: A failure without type attribution is not yet classified as a type error.
What It Is Not¶
- 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.
- Closest near-miss. 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.
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.
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.
Examples¶
Applied / In Practice¶
A function declared to accept a string is called with an integer and no conversion rule applies.
Mapped back: mismatch → The argument type fails the function parameter compatibility judgment before execution..
Applied / In Practice¶
A runtime value stored in a gradual type reaches an operation that requires a list and triggers a type check.
Mapped back: phase → The mismatch exists on the executed path and is detected dynamically rather than rejected globally..
Applied / In Practice¶
An integer denominator is zero in an otherwise well-typed division expression.
Mapped back: boundary → Operand types are compatible; the invalid value belongs to another runtime condition..
Structural Tensions¶
T1 — Early Rejection versus Expressive Flexibility. Stricter static rules catch mismatches sooner but may reject programs whose safe behavior is difficult to prove.
Diagnostic: Evaluate what the type system models and where dynamic checks or annotations are deliberately used.
T2 — Concise Inference versus Diagnostic Transparency. Inference reduces annotations but can make a distant constraint determine an unexpected error location.
Diagnostic: Trace the constraint chain and distinguish root incompatibility from the line where it becomes visible.
Structural–Framed Character¶
The abstraction is structural within formal language semantics. Given typing judgments, compatibility, and a term, the mismatch is precise. Practical diagnostics are framed by compiler design and annotation choices, and different sound systems can draw different boundaries without contradiction.
Structural Core vs. Domain Accent¶
The skeleton is a classification conflict between supplied object and required context. Programming languages supply terms, types, environments, subtyping, inference, compilation, and runtime tags. Without those formal rules the pattern becomes generic incompatibility.
Instantiates / Related Primes¶
-
Approved root. Frozen DAG placement remains unparented.
-
Related — type checking, type safety, and subtyping. These supply the detection process, guarantee, and compatibility relation but are not the error event itself.
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
Not to Be Confused With¶
- Syntax error. Tell: Violates grammatical formation before type compatibility is judged.
- Domain error. Tell: Uses a well-typed value outside an operation's valid numeric or semantic range.
- Type unsafety. Tell: A language property concerning whether type guarantees prevent certain runtime failures.
- Logic error. Tell: Produces unintended behavior while remaining syntactically and type-correct.
References¶
- Frozen Wikipedia discovery revision: https://en.wikipedia.org/wiki/Type_system (revision 1370838121).
- Preserved source candidate: https://www.cs.kent.ac.uk/people/staff/dat/tfp12/tfp12.pdf
- Preserved source candidate: http://gallium.inria.fr/~remy/mpri/cours1.pdf
- Preserved source candidate: https://web.archive.org/web/20171114202221/http://gallium.inria.fr/~remy/mpri/cours1.pdf
- Preserved source candidate: https://www.geeksforgeeks.org/dynamic-method-dispatch-runtime-polymorphism-java/
- Preserved source candidate: https://web.archive.org/web/20201207174217/https://www.geeksforgeeks.org/dynamic-method-dispatch-runtime-polymorphism-java/
- Preserved source candidate: https://dl.acm.org/doi/10.5555/269586
- Preserved source candidate: http://msdn.microsoft.com/en-us/library/dd264741.aspx
- Preserved source candidate: https://doc.rust-lang.org/std/any/index.html
The frozen Wikipedia revision is discovery provenance. The retained source set was reviewed for identity, formal or operational relation, and scope. The encyclopedia's structural synthesis is bounded to those claims; a thin authority surface is recorded as a nonblocking source-strengthening repair rather than concealed.