Skip to content

Odd behaviour of or-patterns with extensible typ #7661

@vicuna

Description

@vicuna

Original bug ID: 7661
Reporter: @thizanne
Assigned to: @maranget
Status: resolved (set by @trefis on 2018-01-09T11:56:53Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 4.05.0
Fixed in version: 4.06.1+dev/rc1/rc2
Category: middle end (typedtree to clambda)
Related to: #5788
Monitored by: @gasche

Bug description

On this example, the evaluation of f A B doesn't go in the (A | B) , B branch. It works as intended if t is a non-extensible sum type. If the two first lines of the pattern matching are inverted, then a has the unexpected '_' value.

type t = ..
type t +=
  | A
  | B

let f x y = match x, y with
  | (A | B), A -> 'a'
  | (A | B), B -> 'b'
  | _, _ -> '_'

let a = f A A (* a : char = 'a' *)
let b = f A B (* b : char = '_' *)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions