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
Left hand sides of the constraint (sty) are kinded using the Any policy (unseen type variables get initialised to the top of the jkind lattice/currently any), while the right hand sides (sty') get Sort (initialised to the highest point below the representable space - currently sort variables).
This leads to the following surprising behaviour (note 'a : any, but 'b is left unbound):
typefloat64 : float64
[%%expect{|typefloat64 : float64
|}]
type('a : any) foo = 'aconstraint'a='b(* 'b gets a sort var, defaults to value *)typefoobar = float64foo
[%%expect{|type'b foo = 'bLine2, characters14-21:
2 | typefoobar = float64foo^^^^^^^Error: Thistypefloat64 should be an instance of type ('a : value)Thelayoutoffloat64isfloat64becauseofthedefinitionoffloat64atline1, characters0-22.Butthelayoutoffloat64mustbeasublayoutofvaluebecauseofthedefinitionoffooatline1, characters0-43.
|}]
type('a : any) foo = 'aconstraint'b='a(* 'b gets any as expected *)typefoobar = float64foo
[%%expect{|type('a : any) foo = 'atypefoobar = float64foo
|}]
After some thinking it seems the correct solution is to use Any in both cases.
The text was updated successfully, but these errors were encountered:
As we found out in discussion with @lpw25, constraints are handled in a somewhat surprising way by
Typedecl.transl_declaration
:flambda-backend/ocaml/typing/typedecl.ml
Lines 752 to 757 in 9e59dbf
Left hand sides of the constraint (
sty
) are kinded using theAny
policy (unseen type variables get initialised to the top of the jkind lattice/currentlyany
), while the right hand sides (sty'
) getSort
(initialised to the highest point below the representable space - currently sort variables).This leads to the following surprising behaviour (note
'a : any
, but'b
is left unbound):After some thinking it seems the correct solution is to use
Any
in both cases.The text was updated successfully, but these errors were encountered: