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

GADT with polymorphic variants bug #5948

vicuna opened this issue Mar 12, 2013 · 1 comment

GADT with polymorphic variants bug #5948

vicuna opened this issue Mar 12, 2013 · 1 comment


Copy link

@vicuna vicuna commented Mar 12, 2013

Original bug ID: 5948
Reporter: @lpw25
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:18:41Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.00.1
Fixed in version: 4.00.2+dev
Category: typing
Child of: #5998
Monitored by: @gasche

Bug description

I came across a typing bug while playing around with GADTs and polymorphic variants. The following code produces a segmentation fault:

type tag = [TagA | TagB | `TagC]

type 'a poly =
AandBTags : [< TagA of int | TagB ] poly
| ATag : [< TagA of int] poly constraint 'a = [< TagA of int | `TagB]

let intA = function TagA i -> i let intB = function TagB -> 4

let intAorB = function
TagA i -> i | TagB -> 4

type _ wrapPoly =
WrapPoly : 'a poly -> ([< TagA of int | TagB] as 'a) wrapPoly

let example6 : type a. a wrapPoly -> (a -> int) =
fun w ->
match w with
| WrapPoly ATag -> intA
| WrapPoly _ -> intA (* This should not be allowed *)

let _ = example6 (WrapPoly AandBTags) `TagB (* This causes a seg fault *)

Copy link

@vicuna vicuna commented Mar 13, 2013

Comment author: @garrigue

Fixed in trunk and 4.00, revisions 13396 and 13397.

Note: you cannot refine variant types whose row variable is rigid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants