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: 7348 Reporter:@lpw25 Assigned to:@garrigue Status: resolved (set by @garrigue on 2017-06-12T14:31:33Z) Resolution: fixed Priority: normal Severity: minor Version: 4.03.0 Target version: 4.06.0 +dev/beta1/beta2/rc1 Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1 Category: typing Monitored by:@gasche@yallop@hcarty
Bug description
The following functor:
module F (X : sig type t = private < foo:int; ..> val x : t end) = struct
let x : < foo: int; ..> = X.x
end
has a return type that includes the private row variable from X:
module F :
functor (X : sig type t = private < foo : int; .. > val x : t end) ->
sig val x : < foo : int; .. > end
This variable remains abstract even when the functor is applied:
module M = struct
type t = < foo: int; bar: int>
let x = object
method foo = 0
method bar = 0
end
end
module N = F(M)
which has type:
module N : sig val x : < foo : int; .. > end
To see that the variable is still abstract:
module L : sig val x : < foo : int; bar : int> end = N;;
Characters 53-54:
module L : sig val x : < foo : int; bar : int> end = N;;
^
Error: Signature mismatch:
Modules do not match:
sig val x : < foo : int; .. > end
is not included in
sig val x : < bar : int; foo : int > end
Values do not match:
val x : < foo : int; .. >
is not included in
val x : < bar : int; foo : int >
let x : < foo : int; bar : int> = N.x;;
Characters 34-37:
let x : < foo : int; bar : int> = N.x;;
^^^
Error: This expression has type < foo : int; .. >
but an expression was expected of type < bar : int; foo : int >
The first object type has no method bar
I suspect that the type is called something like X.t#row and is being substituted to M.t#row which does not exist. This could possibly be
a soundness bug since different functors would produce the same
M.t#row even though they would be different types.
The text was updated successfully, but these errors were encountered:
Indeed the code for abstract rows assumes that they are never visible outside of their scope.
This should be true, as an abstract row can only belong to one type, but the above code reveals an expanded form.
I hope to be able to solve this through the name abbreviation mechanism, but leave it alone for now.
Note: printing the internal types show that the path of the (inexistent) row is correctly propagated, so at least there does not seem to be a soundness problem.
Exploit the fact that inside a module the same type name cannot be used twice, so that the type definition corresponding to a row name is unambiguous.
Ctype.normalize_type fixes printing, Subst,type_expr fixes functor application (both needed).
Original bug ID: 7348
Reporter: @lpw25
Assigned to: @garrigue
Status: resolved (set by @garrigue on 2017-06-12T14:31:33Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.03.0
Target version: 4.06.0 +dev/beta1/beta2/rc1
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: typing
Monitored by: @gasche @yallop @hcarty
Bug description
The following functor:
module F (X : sig type t = private < foo:int; ..> val x : t end) = struct
let x : < foo: int; ..> = X.x
end
has a return type that includes the private row variable from X:
module F :
functor (X : sig type t = private < foo : int; .. > val x : t end) ->
sig val x : < foo : int; .. > end
This variable remains abstract even when the functor is applied:
module M = struct
type t = < foo: int; bar: int>
let x = object
method foo = 0
method bar = 0
end
end
module N = F(M)
which has type:
module N : sig val x : < foo : int; .. > end
To see that the variable is still abstract:
module L : sig val x : < foo : int; bar : int> end = N;;
Characters 53-54:
module L : sig val x : < foo : int; bar : int> end = N;;
^
Error: Signature mismatch:
Modules do not match:
sig val x : < foo : int; .. > end
is not included in
sig val x : < bar : int; foo : int > end
Values do not match:
val x : < foo : int; .. >
is not included in
val x : < bar : int; foo : int >
let x : < foo : int; bar : int> = N.x;;
Characters 34-37:
let x : < foo : int; bar : int> = N.x;;
^^^
Error: This expression has type < foo : int; .. >
but an expression was expected of type < bar : int; foo : int >
The first object type has no method bar
I suspect that the type is called something like X.t#row and is being substituted to M.t#row which does not exist. This could possibly be
a soundness bug since different functors would produce the same
M.t#row even though they would be different types.
The text was updated successfully, but these errors were encountered: