You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6235 Reporter:@alainfrisch Assigned to:@garrigue Status: closed (set by @xavierleroy on 2015-12-11T18:25:15Z) Resolution: fixed Priority: normal Severity: minor Fixed in version: 4.01.1+dev Category: typing Monitored by:@bobzhang@hcarty
Bug description
As reported by Bob Zhang on the caml-list:
type t = { loc : string; }
type v = { loc : string; x : int; }
type u = [ `Key of t ]
let f (u : u) = match u with `Key {loc} -> loc;;
^^^^^^^^^^
Error: This pattern matches values of type [? `Key of v ]
but a pattern was expected which matches values of type u
Types for tag `Key are incompatible
This is surprising, because:
let f (u : u) = match u with `Key loc -> loc.loc
works fine.
The text was updated successfully, but these errors were encountered:
Fixed in 4.01 and trunk, revisions 14284 and 14285.
In trunk, also made principal mode a bit more strict, by keeping different branches of a pattern-matching independent when typing patterns.
I.e., assuming the same type definitions, the following function is refused in principal mode (but accepted in standard mode).
let f = function
| (_ : u) when false -> ""
|`Key {loc} -> loc
Rationale for refusing this: changing the order of branches breaks the typing.
Original bug ID: 6235
Reporter: @alainfrisch
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:25:15Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.01.1+dev
Category: typing
Monitored by: @bobzhang @hcarty
Bug description
As reported by Bob Zhang on the caml-list:
This is surprising, because:
works fine.
The text was updated successfully, but these errors were encountered: