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
let rec get_var : type stk ret. (stk s, ret) var -> stk lst -> ret = fun n s ->
match n, s with
| Head, CCons (h, ) -> h
| Tail n', CCons (, t) -> get_var n' t
The first case is the correct behaviour, because an abstract type from another module could be equal to a function type. The second case could probably be improved, since a type with a Cstr constructor could not be equal to a function type.
Original bug ID: 6817
Reporter: @chambart
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:47:26Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.03.0+dev / +beta1
Fixed in version: 4.02.2+dev / +rc1
Category: typing
Monitored by: @diml @yallop
Bug description
This code is correctly checked for exhaustiveness if defined like this. But
if nil is declared in another module, it breaks
type nil
type _ s =
| Nil : nil s
| Cons : 't s -> ('h -> 't) s
type ('stack, 'typ) var =
| Head : (('typ -> ) s, 'typ) var
| Tail : ('tail s, 'typ) var -> (( -> 'tail) s, 'typ) var
type _ lst =
| CNil : nil lst
| CCons : 'h * ('t lst) -> ('h -> 't) lst
let rec get_var : type stk ret. (stk s, ret) var -> stk lst -> ret = fun n s ->
match n, s with
| Head, CCons (h, ) -> h
| Tail n', CCons (, t) -> get_var n' t
For instance if we replace
type nil
withmodule A = struct
type nil
end
open A
Or even
module A = struct
type nil = Cstr
end
open A
Notice that
type nil = unit
works.File attachments
The text was updated successfully, but these errors were encountered: