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

Surprising "This ground coercion is not principal" warning #7135

Closed
vicuna opened this issue Feb 4, 2016 · 2 comments
Closed

Surprising "This ground coercion is not principal" warning #7135

vicuna opened this issue Feb 4, 2016 · 2 comments
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Feb 4, 2016

Original bug ID: 7135
Reporter: @yallop
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-09-24T15:32:09Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)
Related to: #7199
Monitored by: @hcarty

Bug description

The following program causes OCaml to issue a warning

   $ cat princ.ml
   module M : sig type t = private int end =
   struct type t = int end
   include M

   let lift2 (f : int -> int -> int) (x : t) (y : t) =
     f (x :> int) (y :> int)
   $ ocamlc princ.ml
   File "princ.ml", line 6, characters 15-25:
   Warning 18: this ground coercion is not principal.

This is surprising for several reasons. First, in what sense is the coercion not principal? Both the source and the target type are known. Second, only one of the apparently-identical coercions is flagged as non-principal. Third, changing 'include' to 'open' causes the warning to disappear.

@vicuna
Copy link
Author

vicuna commented Feb 4, 2016

Comment author: @garrigue

Note that with -principal, the warning goes away.
The problem is that this warning tries to do the same thing as -principal, but with less work, and this is not correct.
I suppose the solution is to disable it when -principal is off.

(Technically the reason is probably that, when -principal is off, type constructors without arguments can be physically shared, so that they may look like they are not "fresh" enough to be principal.)

@vicuna
Copy link
Author

vicuna commented Feb 5, 2016

Comment author: @garrigue

Fixed by disabling the warning when not in -principal mode.
There is no way to provide correct principality warnings without -principal.

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