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

Misbehaviour with abstracted structural type used as GADT index #5785

vicuna opened this Issue Oct 11, 2012 · 1 comment


None yet
2 participants
Copy link

vicuna commented Oct 11, 2012

Original bug ID: 5785
Reporter: @yallop
Assigned to: @garrigue
Status: closed (set by @garrigue on 2012-10-12T01:44:21Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 4.00.1
Fixed in version: 4.00.2+dev
Category: typing
Child of: #5998
Monitored by: @diml @alainfrisch

Bug description

$ cat
module Add (T : sig type two end) =
type _ t =
| One : [`One] t
| Two : T.two t

let add (type a) : a t * a t -> string = function
| One, One -> "two"
| Two, Two -> "four"

module M = Add(struct type two = [`One] end)

let _ =
print_endline (M.add (M.One, M.Two));
print_endline (M.add (M.Two, M.One));
$ ocamlc -w A -o test
$ ./test

File attachments


This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Oct 12, 2012

Comment author: @garrigue

Indeed, the fact that a structural type may be compatible with an aliasable type was not taken into account in the compatibility check, and as a result the pattern-matching was wrongly deemed exhaustive.
This is fixed in 4.00 and trunk, at revisions 13009 and 13008.

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.