Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003984OCamlOCaml generalpublic2006-03-04 16:332015-02-24 23:35
Assigned To 
PlatformOSOS Version
Product Version3.09.1 
Target Versionafter-4.02.2Fixed in Version 
Summary0003984: Compiler ignores types in .cmi file [problems with #trace]
DescriptionThe OCaml compiler (ocamlc) seems to ignore the function declarations
in .cmi files, allowing wrongly typed expressions. This bug was
discovered when using #trace where it lead to a segmentation violation.

Files attached (in ocamlbug.tar): test.mli, and
Compile test.mli then
ocamlc -c test.mli
ocamlc -c

Run the script:

The compiler should fail on but doesn't and running the script
leads to a segfault.

Additional InformationThe system used is OCaml version 3.09.1 on Linux-x86.
TagsNo tags attached.
Attached Filestar file icon ocamlbug.tar [^] (10,240 bytes) 2006-03-04 16:33

- Relationships

-  Notes
Christophe (reporter)
2006-03-05 09:18

This is not a bug of ocamlc. The mli file constraints the types outside of the module, not inside !
In your example, the type of log is
val log : 'a -> 'b -> unit
inside module test, but outside it is what you wrote in test.mli

The only bug is in the directive #trace that follows the public type not the private....
It can be seen with simpler examples :

# module T: sig val f : int -> unit val g: 'a -> unit end = struct let f x = ignore x let g x = f x end;;
module T : sig val f : int -> unit val g : 'a -> unit end
# #trace T.f;;
T.f is now traced.
# T.g 'a';;
T.f <-- 97
T.f --> ()
- : unit = ()

Of course, it must not do a seg fault when printing some "impossible value" (so there is something to be fixed (?), even if it does not crach on most example, but if you use string instead of int in the simple example, it crashes because it does not verify that the "string" is well formed... )
I am not sure it must be fixed (it seems using #trace is like using module Obj.... it must be done with careful knowledge)

- Issue History
Date Modified Username Field Change
2006-03-04 16:33 mwahab New Issue
2006-03-04 16:33 mwahab File Added: ocamlbug.tar
2006-03-05 09:18 Christophe Note Added: 0003586
2006-03-29 16:23 doligez Severity minor => tweak
2006-03-29 16:23 doligez Status new => acknowledged
2006-03-29 16:23 doligez Summary Compiler ignores types in .cmi file => Compiler ignores types in .cmi file [problems with #trace]
2006-03-29 16:23 doligez Description Updated
2006-03-29 16:23 doligez Additional Information Updated
2006-03-29 16:42 doligez Category Incoming => OCaml general
2012-09-06 16:43 doligez Target Version => 4.00.1+dev
2012-09-11 14:47 doligez Target Version 4.00.1+dev => 4.01.0+dev
2013-07-24 11:52 doligez Target Version 4.01.0+dev => 4.01.1+dev
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-07-16 20:59 doligez Target Version 4.02.0+dev => 4.02.1+dev
2014-07-16 21:00 doligez Target Version 4.02.1+dev => 4.02.0+dev
2014-07-21 18:02 doligez Severity tweak => minor
2014-07-21 18:02 doligez Status acknowledged => confirmed
2014-07-21 18:02 doligez Target Version 4.02.0+dev => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2014-09-25 16:29 doligez Target Version undecided => 4.02.2+dev / +rc1
2015-02-24 23:35 doligez Target Version 4.02.2+dev / +rc1 => after-4.02.2

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker