You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 3984 Reporter: mwahab Assigned to:@garrigue Status: closed (set by @xavierleroy on 2017-02-16T14:14:57Z) Resolution: fixed Priority: normal Severity: minor Version: 3.09.1 Target version: 4.03.0+dev / +beta1 Category: ~DO NOT USE (was: OCaml general)
Bug description
The 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, test.ml and script.ml.
Compile test.mli then test.ml:
ocamlc -c test.mli
ocamlc -c test.ml
Run the script:
ocaml script.ml
The compiler should fail on test.ml but doesn't and running the script
leads to a segfault.
Additional information
The system used is OCaml version 3.09.1 on Linux-x86.
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)
As pointed out there is nothing wrong in the semantics.
The segmentation fault in #trace would of course be a bug, but it seems that it has been fixed long ago.
Original bug ID: 3984
Reporter: mwahab
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-02-16T14:14:57Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.09.1
Target version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)
Bug description
The 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, test.ml and script.ml.
Compile test.mli then test.ml:
ocamlc -c test.mli
ocamlc -c test.ml
Run the script:
ocaml script.ml
The compiler should fail on test.ml but doesn't and running the script
leads to a segfault.
Additional information
The system used is OCaml version 3.09.1 on Linux-x86.
File attachments
The text was updated successfully, but these errors were encountered: