Guest User

Untitled

a guest
Feb 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. Index: testsuite/tests/typing-poly/poly.ml
  2. ===================================================================
  3. --- testsuite/tests/typing-poly/poly.ml (revision 15774)
  4. +++ testsuite/tests/typing-poly/poly.ml (working copy)
  5. @@ -667,3 +667,19 @@
  6.  
  7. match (fun x -> x), fun x -> x with x, y -> x, y;;
  8. match fun x -> x with x -> x, x;;
  9. +
  10. +(* PR#6747 *)
  11. +(* ok *)
  12. +let n = object
  13. + method m : 'x 'o. ([< `Foo of 'x] as 'o) -> 'x = fun x -> assert false
  14. +end;;
  15. +(* ok, but not with -principal *)
  16. +let n =
  17. + object method m : 'x. [< `Foo of 'x] -> 'x = fun x -> assert false end;;
  18. +(* fail *)
  19. +let (n : < m : 'a. [< `Foo of int] -> 'a >) =
  20. + object method m : 'x. [< `Foo of 'x] -> 'x = fun x -> assert false end;;
  21. +(* fail *)
  22. +let (n : 'b -> < m : 'a . ([< `Foo of int] as 'b) -> 'a >) = fun x ->
  23. + object method m : 'x. [< `Foo of 'x] -> 'x = fun x -> assert false end;;
  24. +
  25. Index: typing/ctype.ml
  26. ===================================================================
  27. --- typing/ctype.ml (revision 15774)
  28. +++ typing/ctype.ml (working copy)
  29. @@ -2744,6 +2744,19 @@
  30. if List.memq ty tl then remq tl tl' else ty :: remq tl tl'
  31. in
  32. let tl2' = remq tl2 tl1 and tl1' = remq tl1 tl2 in
  33. + (* PR#6744 *)
  34. + let split_univars =
  35. + List.partition
  36. + (fun ty -> try occur_univar !env ty; true with Unify _ -> false) in
  37. + let (tl1',tlu1) = split_univars tl1'
  38. + and (tl2',tlu2) = split_univars tl2' in
  39. + begin match tlu1, tlu2 with
  40. + [], [] -> ()
  41. + | (tu1::tlu1), (tu2::_) ->
  42. + (* Attempt to merge all the types containing univars *)
  43. + List.iter (unify env tu1) (tlu1@tlu2)
  44. + | (tu::_, []) | ([], tu::_) -> occur_univar !env tu
  45. + end;
  46. (* Is this handling of levels really principal? *)
  47. List.iter (update_level !env (repr more).level) (tl1' @ tl2');
  48. let e = ref None in
Add Comment
Please, Sign In to add comment