Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10822: Bad interaction between ambivalent types and subtyping coercions #10823

Merged
merged 2 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ OCaml 4.14.0
- #10763, #10764: fix miscompilation of method delegation
(Alain Frisch, review by Vincent Laviron and Jacques Garrigue)

- #10822, #10823: Bad interaction between ambivalent types and subtyping
coercions (Jacques Garrigue, report and review by Frédéric Bour)


OCaml 4.13 maintenance branch
-----------------------------
Expand Down
16 changes: 16 additions & 0 deletions testsuite/tests/typing-gadts/principality-and-gadts.ml
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,19 @@ let bar x =
[%%expect{|
val bar : string foo -> string = <fun>
|}]

(* #10822 *)
type t
type u = private t
type ('a, 'b) eq = Refl : ('a, 'a) eq
[%%expect{|
type t
type u = private t
type ('a, 'b) eq = Refl : ('a, 'a) eq
|}]

let foo (type s) x (Refl : (s, u) eq) =
(x : s :> t)
[%%expect{|
val foo : 's -> ('s, u) eq -> t = <fun>
|}]
8 changes: 4 additions & 4 deletions typing/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3459,15 +3459,15 @@ and type_expect_
and (cty', ty', force') =
Typetexp.transl_simple_type_delayed env sty'
in
end_def ();
generalize_structure ty;
generalize_structure ty';
begin try
let force'' = subtype env ty ty' in
let force'' = subtype env (instance ty) (instance ty') in
force (); force' (); force'' ()
with Subtype err ->
raise (Error(loc, env, Not_subtype err))
end;
end_def ();
generalize_structure ty;
generalize_structure ty';
(type_argument env sarg ty (instance ty),
instance ty', Some cty, cty')
in
Expand Down