Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Strange type system bug #7192
Original bug ID: 7192
After a day filled with crying spells and intermittent manic laughter I have finally managed to excise a reproducible example with less than 1 KLOC from approx. 30 KLOCs for one of the hardest to reproduce type system bugs I have seen so far.
Not only is the compiler clearly confused, the most bizarre property of this bug is that the emitted type error of the example will likely disappear if you change completely unrelated and distant parts of the remaining code. Simply adding or removing superfluous bindings in the implementation or in interfaces almost anywhere in the code will likely do that for you (no guarantees - it depends...).
The nature of the bug suggests a major corruption of some lookup tables for signatures used by the type checker. Maybe there is a hash collision that doesn't get correctly disambiguated, or maybe some indexes in a lookup table get incorrectly shifted somehow. Maybe there is even a marshaling bug when writing out the compilation files. It's mysterious.
Steps to reproduce
Install OCaml 4.02.3 and the Jane Street Core library (I didn't manage to excise the example without it), extract the attached archive, then call "ocamlbuild -use-ocamlfind foo_impl.cmo".
The type error I get on both Mac OS X and Linux is:
File "foo_impl.ml", line 1: