Skip to content

Fix arrow printing when closing over unknown mode #1744

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

Merged
merged 3 commits into from
Aug 15, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions ocaml/testsuite/tests/typing-local/local.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2630,3 +2630,33 @@ Error: This local value escapes its region
Hint: This is a partial application
Adding 1 more argument will make the value non-local
|}]

(* Reported internal to Jane Street as COMPILERS-1504 *)

module M : sig
val f : string -> string -> local_ string
end = struct
let g x y = local_ "foo"
let f x = local_ g x
end;;
[%%expect{|
Lines 3-6, characters 6-3:
3 | ......struct
4 | let g x y = local_ "foo"
5 | let f x = local_ g x
6 | end..
Error: Signature mismatch:
Modules do not match:
sig
val g : 'a -> 'b -> local_ string
val f : 'a -> local_ ('b -> local_ string)
end
is not included in
sig val f : string -> string -> local_ string end
Values do not match:
val f : 'a -> local_ ('b -> local_ string)
is not included in
val f : string -> string -> local_ string
The type string -> local_ (string -> local_ string)
is not compatible with the type string -> string -> local_ string
|}]
5 changes: 2 additions & 3 deletions ocaml/typing/oprint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,11 @@ and print_out_arg am ppf ty =
and print_out_ret mode rm ppf ty =
match mode, rm with
| Oam_local, Oam_local
| Oam_global, Oam_global
| Oam_unknown, _
| _, Oam_unknown -> print_out_type_1 rm ppf ty
| Oam_global, Oam_global -> print_out_type_1 rm ppf ty
| _, Oam_local ->
print_out_type_local rm ppf ty
| _, Oam_global -> print_out_type_2 rm ppf ty
| _, Oam_unknown -> print_out_type_1 rm ppf ty

and print_out_type_local m ppf ty =
if Language_extension.is_enabled Local then begin
Expand Down