Skip to content

Commit

Permalink
typing: fix a try_expand_once forgotten from ocaml#10170
Browse files Browse the repository at this point in the history
Reported-by: Neven Villani <vanille@crans.org>
  • Loading branch information
gasche committed Feb 15, 2024
1 parent 3f2aa11 commit 2d7053b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,10 @@ OCaml 4.14 maintenance version
- #12878: fix incorrect treatment of injectivity for private recursive types.
(Jeremy Yallop, review by Gabriel Scherer and Jacques Garrigue)

- #12971, #12974: fix an uncaught Ctype.Escape exception on some
invalid programs forming recursive types.
(Gabriel Scherer, review by Florian Angeletti, report by Neven Villani)

- #12264, #12289: Fix compact_allocate to avoid a pathological case
that causes very slow compaction.
(Damien Doligez, report by Arseniy Alekseyev, review by Sadiq Jaffer)
Expand Down
10 changes: 6 additions & 4 deletions testsuite/tests/typing-misc/occur_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ val wrong_to_seq : ('a Seq.t as 'a) Seq.t t -> 'a Seq.t Seq.t = <fun>

let strange x = Seq.[cons x empty; cons empty x];;
[%%expect{|
Uncaught exception: Ctype.Escape(_)

|}, Principal{|
val strange : 'a Seq.t Seq.t -> 'a Seq.t Seq.t Seq.t list = <fun>
Line 1, characters 12-48:
1 | let strange x = Seq.[cons x empty; cons empty x];;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type "('a Seq.t as 'a) Seq.t -> 'a Seq.t Seq.t list"
but an expression was expected of type
"('a Seq.t as 'a) Seq.t -> 'a Seq.t Seq.t list"
|}];;
2 changes: 1 addition & 1 deletion typing/ctype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ let rec occur_rec env allow_recursive visited ty0 ty =
let visited = TypeSet.add ty visited in
iter_type_expr (occur_rec env allow_recursive visited ty0) ty
with Occur -> try
let ty' = try_expand_head try_expand_once env ty in
let ty' = try_expand_head try_expand_safe env ty in
(* This call used to be inlined, but there seems no reason for it.
Message was referring to change in rev. 1.58 of the CVS repo. *)
occur_rec env allow_recursive visited ty0 ty'
Expand Down

0 comments on commit 2d7053b

Please sign in to comment.