A curated collection of counterexamples that demonstrate limitations and pitfalls in type systems, serving as an educational resource for programmers and language designers.
# Counterexamples in Type Systems - Counterexamples in Type Systems
Source: [https://counterexamples.org/](https://counterexamples.org/)
1. [Counterexamples in Type Systems](https://counterexamples.org/title.html)
2. [Introduction](https://counterexamples.org/intro.html)
3. [Index and Glossary](https://counterexamples.org/glossary.html)
4. [**1\.**Polymorphic references](https://counterexamples.org/polymorphic-references.html)
5. [**2\.**Covariant containers](https://counterexamples.org/general-covariance.html)
6. [**3\.**Incomplete variance checking](https://counterexamples.org/incomplete-variance.html)
7. [**4\.**Objects under construction](https://counterexamples.org/under-construction.html)
8. [**5\.**Curry's paradox](https://counterexamples.org/currys-paradox.html)
9. [**6\.**Eventually, nothing](https://counterexamples.org/eventually-nothing.html)
10. [**7\.**Dubious evidence](https://counterexamples.org/dubious-evidence.html)
11. [**8\.**Some kinds of Anything](https://counterexamples.org/anythings.html)
12. [**9\.**Any \(single\) thing](https://counterexamples.org/anything-once.html)
13. [**10\.**Mutable matching](https://counterexamples.org/mutable-matching.html)
14. [**11\.**Runtime type misinformation](https://counterexamples.org/runtime-misinformation.html)
15. [**12\.**Overloading and polymorphism](https://counterexamples.org/overloading-polymorphism.html)
16. [**13\.**Distinctness I: Injectivity](https://counterexamples.org/distinctness-injectivity.html)
17. [**14\.**Distinctness II: Recursion](https://counterexamples.org/distinctness-recursion.html)
18. [**15\.**Distinctness III: Options](https://counterexamples.org/distinctness-options.html)
19. [**16\.**Subtyping vs\. inheritance](https://counterexamples.org/subtyping-vs-inheritance.html)
20. [**17\.**Selfishness](https://counterexamples.org/selfishness.html)
21. [**18\.**Privacy violation](https://counterexamples.org/privacy-violation.html)
22. [**19\.**Unstable type expressions](https://counterexamples.org/unstable-types.html)
23. [**20\.**The avoidance problem](https://counterexamples.org/avoidance.html)
24. [**21\.**A little knowledge\.\.\.](https://counterexamples.org/little-knowledge.html)
25. [**22\.**Underdetermined recursion](https://counterexamples.org/underdetermined-recursion.html)
26. [**23\.**Overdetermined recursion](https://counterexamples.org/overdetermined-recursion.html)
27. [**24\.**Scope escape](https://counterexamples.org/scope-escape.html)
28. [**25\.**Under false pretenses](https://counterexamples.org/false-pretenses.html)
29. [**26\.**Suspicious subterms](https://counterexamples.org/suspicious-subterms.html)
30. [**27\.**There's only one Leibniz](https://counterexamples.org/only-one-leibniz.html)
31. [**28\.**Intersecting references](https://counterexamples.org/intersecting-references.html)
32. [**29\.**Polymorphic union refinement](https://counterexamples.org/polymorphic-union-refinement.html)
33. [**30\.**Positivity, strict and otherwise](https://counterexamples.org/strict-positivity.html)
34. [**31\.**Nearly\-universal quantification](https://counterexamples.org/nearly-universal.html)
## Counterexamples in Type Systems
[https://counterexamples.org/print.html](https://counterexamples.org/print.html)[https://github.com/stedolan/counterexamples](https://github.com/stedolan/counterexamples)
## [Counterexamples in Type Systems](https://counterexamples.org/#counterexamples-in-type-systems)
*collated by Stephen Dolan, with thanks to Andrej Bauer, Leo White and Jeremy Yallop*
[https://counterexamples.org/intro.html](https://counterexamples.org/intro.html)
[https://counterexamples.org/intro.html](https://counterexamples.org/intro.html)
Argues that TypeScript is a poor default for the AI era due to its unsound type system, which fails to catch errors in AI-generated code, and likens it to Paul Graham's Blub paradox.
A deep dive into existential quantification in Rust's type system, comparing `dyn Trait` and `impl Trait`, and exploring advanced patterns for existentially quantified type variables beyond `Self`.
The author argues that the resurgence of static typing in the 2010s was due to improved type systems (e.g., TypeScript, Haskell, Rust) that offer nullable type handling, sum types, and type inference, contrasting with poor static typing in earlier languages like Java and C++98.
A blog post presents a toy language that enforces borrow-checking at runtime without static typing, using cheap reference-counting on the stack to enable interior pointers and single ownership in a dynamically-typed setting.
A technical blog post discussing how structural descriptions like type systems and build systems leverage graph-structured models to ensure correctness, highlighting the definitional nature of systems like Bazel.