Skip to content
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

Compiler ignores types in .cmi file [problems with #trace] #3984

Closed
vicuna opened this issue Mar 4, 2006 · 2 comments
Closed

Compiler ignores types in .cmi file [problems with #trace] #3984

vicuna opened this issue Mar 4, 2006 · 2 comments
Assignees
Labels
Milestone

Comments

@vicuna
Copy link

vicuna commented Mar 4, 2006

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

@vicuna
Copy link
Author

vicuna commented Mar 5, 2006

Comment author: Christophe

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)

@vicuna
Copy link
Author

vicuna commented Sep 9, 2015

Comment author: @garrigue

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.

@vicuna vicuna closed this as completed Feb 16, 2017
@vicuna vicuna added this to the 4.03.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants