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: 6124 Reporter:@lpw25 Assigned to:@garrigue Status: resolved (set by @garrigue on 2017-03-14T10:07:41Z) Resolution: fixed Priority: normal Severity: minor Version: 4.01.0+dev Target version: undecided Fixed in version: 4.06.0 +dev/beta1/beta2/rc1 Category: typing Monitored by:@lpw25
Bug description
I'm sure Jacques is already aware of this behaviour, but I find the following behaviour a bit odd, and at the very least the error message could be improved:
let f : ([A | B ] as 'a) -> [> 'a ] -> unit = fun x y -> ();;
val f : [ A | B ] -> [> A | B ] -> unit =
let f : ([A | B ] as 'a) -> [> 'a] -> unit = fun x (y : [> 'a]) -> ();;
Characters 61-63:
let f : ([A | B ] as 'a) -> [> 'a] -> unit = fun x (y : [> 'a]) -> ();;
^^
Error: The type 'a is not a polymorphic variant type
let f (x : [A | B] as 'a) (y : [> 'a]) = ();;
Characters 36-38:
let f (x : [A | B] as 'a) (y : [> 'a]) = ();;
^^
Error: The type 'a is not a polymorphic variant type
The text was updated successfully, but these errors were encountered:
For principality reasons, bindings of type variables are not propagated to pattern-matchings containing polymorphic variants.
Improving the error message is possible, but this seems lots of code to little effect: one has to check whether the type is a variable, and whether its actual binding is a polymorphic variant or not, to finally decide outputting a very specialized error message...
Another approach is to restrict syntactically: polymorphic variant inheritance is only intended to be used with defined types.
Another approach is to restrict syntactically: polymorphic variant inheritance is only intended to be used with defined types.
I think that this would be a good idea, because it probably works for all the actual code out there and is less confusing for people.
Improving the error message is possible, but this seems lots of code to little effect: one has to check whether the type is a variable, and whether its actual binding is a polymorphic variant or not, to finally decide outputting a very specialized error message...
I actually just meant changing the wording because the statement "'a is not a polymorphic variant type" is not really true, so a wording that is more clear that 'a is not known to be a polymorphic variant type when defining [> 'a] would be less confusing. Basically the current error sounds a bit too much like a unification error, whilst 'a can clearly be unified with a polymorphic variant.
Original bug ID: 6124
Reporter: @lpw25
Assigned to: @garrigue
Status: resolved (set by @garrigue on 2017-03-14T10:07:41Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.01.0+dev
Target version: undecided
Fixed in version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Monitored by: @lpw25
Bug description
I'm sure Jacques is already aware of this behaviour, but I find the following behaviour a bit odd, and at the very least the error message could be improved:
let f : ([
A |
B ] as 'a) -> [> 'a ] -> unit = fun x y -> ();;val f : [
A |
B ] -> [>A |
B ] -> unit =let f : ([
A |
B ] as 'a) -> [> 'a] -> unit = fun x (y : [> 'a]) -> ();;Characters 61-63:
let f : ([
A |
B ] as 'a) -> [> 'a] -> unit = fun x (y : [> 'a]) -> ();;^^
Error: The type 'a is not a polymorphic variant type
let f (x : [
A |
B] as 'a) (y : [> 'a]) = ();;Characters 36-38:
let f (x : [
A |
B] as 'a) (y : [> 'a]) = ();;^^
Error: The type 'a is not a polymorphic variant type
The text was updated successfully, but these errors were encountered: