Skip to content

GADT constructor disambiguation in pattern matching #6852

@vicuna

Description

@vicuna

Original bug ID: 6852
Reporter: @Drup
Status: closed (set by @alainfrisch on 2015-04-28T16:51:46Z)
Resolution: duplicate
Priority: normal
Severity: minor
Version: 4.02.1
Category: typing
Duplicate of: #6023

Bug description

At the moment, the compiler refuses to disambiguate GADT by telling you explicitly "The GADT constructor must be qualified in this pattern".

It puzzles me a bit, because it means the typechecker actually already found it was a GADT (hence found the type ..) and then refuses to disambiguate.

Also, with ADTs, you can disambiguate one branch of a patter matching and the other branches will not be considered ambiguous. There is no such thing for GADT and the compiler will still refuse to typechecker if only one branch is disambiguated.

For example, I would like to be able to at least write this:

module M = struct
type _ t =
| I : int t
| S : string t
end

let f : type x . x M.t -> x
= function
| M.I -> 3
| S -> "bla"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions