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

Type-directed propagation fails to disambiguate variants that are also exception constructors #6872

Closed
vicuna opened this issue May 15, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented May 15, 2015

Original bug ID: 6872
Reporter: @gasche
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:49:20Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.1
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.02.2+dev / +rc1
Category: typing
Child of: #6871
Monitored by: @diml @hcarty

Bug description

When a potentially-ambiguous variant constructor has "exn" has one possible type, it always raise Warning 41, even if type-directed propagation successfully disambiguated it.

$ opam config exec --switch=4.02.1 -- ocaml -w A
OCaml version 4.02.1

type a = A;;

type a = A

exception A;;

exception A

raise A;;

Warning 41: A belongs to several types: exn a
The first one was selected. Please disambiguate if this is wrong.
Exception: A.

raise (A : exn);;

Warning 41: A belongs to several types: exn a
The first one was selected. Please disambiguate if this is wrong.
Exception: A.

let f (x : exn) = ();;

Warning 27: unused variable x.
val f : exn -> unit =

f A;;

Warning 41: A belongs to several types: exn a
The first one was selected. Please disambiguate if this is wrong.

  • : unit = ()

This is highly problematic in trunk because the Error constructor introduced in the ('a, 'b) result type in Pervasives makes user-defined Error exception-constructors ambiguous, which litters some user code with dozens of unjustified Warning 41 instances. This was raised by Romain Beauxis in
#147 (comment)
and #6871.

@vicuna

This comment has been minimized.

Copy link
Author

commented May 15, 2015

Comment author: @lpw25

I assume that this is because disambiguation is not yet supported for exceptions (and other extensible variants).

@vicuna

This comment has been minimized.

Copy link
Author

commented May 17, 2015

Comment author: @garrigue

Fixed in 4.02 and trunk at revisions 16120 and 16121.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.