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

Closed
vicuna opened this issue Mar 12, 2013 · 1 comment
Closed

GADT with polymorphic variants bug #5948

vicuna opened this issue Mar 12, 2013 · 1 comment
Assignees
Labels
bug typing typing-GADTS GADT typing and exhaustiveness bugs

Comments

@vicuna
Copy link

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 *)

@vicuna
Copy link
Author

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.

@vicuna vicuna closed this as completed Dec 11, 2015
@vicuna vicuna added the typing label Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
@Octachron Octachron added the typing-GADTS GADT typing and exhaustiveness bugs label May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug typing typing-GADTS GADT typing and exhaustiveness bugs
Projects
None yet
Development

No branches or pull requests

3 participants