Original bug ID: 6993
Reporter: @stedolan
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-02-16T14:14:49Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.3
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Related to: #7016
Monitored by: @gasche @diml @yallop @hcarty
Bug description
Without -rectypes, the exhaustiveness checker "knows" that there is no type t = t list, and so accepts this definition as exhaustive (and optimises away the actual match check):
type (_, _) eqp = Y : ('a, 'a) eqp | N : string -> ('a, 'b) eqp
let f : ('a list, 'a) eqp -> unit = function N s -> print_string s
Using recursive modules, we can construct a type t = t list, even without -rectypes:
module rec A : sig
type t = B.t list
end = struct
type t = B.t list
end and B : sig
type t
val eq : (B.t list, t) eqp
end = struct
type t = A.t
let eq = Y
end
The expression "f B.eq" segfaults.
This example does not segfault with -rectypes, since in that case the exhaustiveness checker does not assume t = t list is impossible.
Original bug ID: 6993
Reporter: @stedolan
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-02-16T14:14:49Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.3
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Related to: #7016
Monitored by: @gasche @diml @yallop @hcarty
Bug description
Without -rectypes, the exhaustiveness checker "knows" that there is no type t = t list, and so accepts this definition as exhaustive (and optimises away the actual match check):
type (_, _) eqp = Y : ('a, 'a) eqp | N : string -> ('a, 'b) eqp
let f : ('a list, 'a) eqp -> unit = function N s -> print_string s
Using recursive modules, we can construct a type t = t list, even without -rectypes:
module rec A : sig
type t = B.t list
end = struct
type t = B.t list
end and B : sig
type t
val eq : (B.t list, t) eqp
end = struct
type t = A.t
let eq = Y
end
The expression "f B.eq" segfaults.
This example does not segfault with -rectypes, since in that case the exhaustiveness checker does not assume t = t list is impossible.