New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange type system bug #7192
Comments
Comment author: @yallop Which version of Core are you using? I couldn't reproduce this with OCaml 4.02.3 and Core 113.33.00. |
Comment author: @xavierleroy The fact that this bug is very sensitive to the number and order of bindings suggests a name capture / lack of alpha-conversion over identifiers somewhere... but I have no idea where. |
Comment author: @damiendoligez Unless I'm mistaken, the bug is at lines 1483--1486 of typing/env.ml and it's been there since March 2000. It is indeed a name capture. |
Comment author: @damiendoligez Looks like this bug is a variant of #6651 and was fixed by commit dcb6a4d. |
Comment author: @xavierleroy Optimistically assuming this was fixed along with #6651. Reopen if not. |
Original bug ID: 7192
Reporter: @mmottl
Status: resolved (set by @xavierleroy on 2017-02-16T13:18:53Z)
Resolution: fixed
Priority: normal
Severity: major
Platform: Mac and Linux
Version: 4.02.3
Target version: undecided
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Related to: #2388 #6651
Monitored by: @gasche @diml @hcarty @alainfrisch @mmottl @garrigue
Bug description
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:
Error: The implementation foo_impl.ml
does not match the interface foo_impl.cmi:
...
At position
module Close(Blah)() :
sig module Par : sig module Join : end end
Type declarations do not match:
type t = Blah.Par.Join.t
is not included in
type t = Foo_intf.Blah.Par.Join.t
File "foo_impl.ml", line 159, characters 25-40: Actual declaration
The above makes no sense. There is no module path to "Foo_intf.Blah.Par".
But you can make this error easily disappear: just remove e.g. "let f1 = ..." near the top of "foo_impl.ml". This function is used nowhere and doesn't appear in any interfaces. Confused? Undo the change and now duplicate "f1" and make it "f3". The error disappears, too. Add or remove an argument. Same thing. Edit the "sigs.ml" file: just adding or removing any of the seemingly superfluous "val x..." entries or adding new superfluous types to the signatures can make the error disappear or reappear depending on what you do. Even adding or removing dummy bindings in the body of some functions in "foo_impl.ml" can change everything.
File attachments
The text was updated successfully, but these errors were encountered: