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

Closed
vicuna opened this Issue Oct 11, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

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 test.ml
module Add (T : sig type two end) =
struct
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"
end

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

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

File attachments

@vicuna

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.