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 return mode for eta-expanded function in type_argument #735

Merged
merged 1 commit into from
Jul 19, 2022
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
11 changes: 11 additions & 0 deletions ocaml/testsuite/tests/typing-local/type_arg_bug.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(* TEST *)
module Bug : sig
end = struct
let app fn = fn 1 2 3
let pair_opt ?opt:_ ~kw:_ a b c = a + b + c
let[@inline never] go () =
app (pair_opt ~kw:())
let _ =
Printf.printf "%d\n" (go ())
end

1 change: 1 addition & 0 deletions ocaml/testsuite/tests/typing-local/type_arg_bug.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6
11 changes: 5 additions & 6 deletions ocaml/typing/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5216,14 +5216,13 @@ and type_argument ?explanation ?recarg env (mode : expected_mode) sarg
let inferred = is_inferred sarg in
let rec loosen_ret_modes ty' ty =
match expand_head env ty', expand_head env ty with
| {desc = Tarrow((l', marg', mret'), ty_arg', ty_res', _); level = lv'},
{desc = Tarrow((l, marg, mret ), ty_arg, ty_res, _); level = lv }
| {desc = Tarrow((l, marg, mret), ty_arg', ty_res', _); level = lv'},
{desc = Tarrow(_, ty_arg, ty_res, _); level = lv }
when lv' = generic_level || not !Clflags.principal ->
let ty_res', ty_res = loosen_ret_modes ty_res' ty_res in
let mret', _ = Alloc_mode.newvar_below mret' in
let mret, _ = Alloc_mode.newvar_below mret in
newty2 lv' (Tarrow((l', marg', mret'), ty_arg', ty_res', Cok)),
newty2 lv (Tarrow((l, marg, mret), ty_arg, ty_res, Cok))
let mret, _ = Alloc_mode.newvar_below mret in
newty2 lv' (Tarrow((l, marg, mret), ty_arg', ty_res', Cok)),
newty2 lv (Tarrow((l, marg, mret), ty_arg, ty_res, Cok))
| _ ->
ty', ty
in
Expand Down