Skip to content

Commit c31f6c3

Browse files
authored
flambda-backend: Fix treatment of functions called [@nontail] (#725)
1 parent 847781e commit c31f6c3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

testsuite/tests/typing-local/local.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,13 @@ let foo x =
10901090
val foo : string -> unit = <fun>
10911091
|}]
10921092

1093+
let foo x =
1094+
let local_ f () = 42 in
1095+
f () [@nontail]
1096+
[%%expect{|
1097+
val foo : 'a -> int = <fun>
1098+
|}]
1099+
10931100
(* Cannot call local values in tail calls *)
10941101

10951102
let foo x =

typing/typecore.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,12 +3500,13 @@ and type_expect_
35003500
{ exp with exp_loc = loc }
35013501
| Pexp_apply(sfunct, sargs) ->
35023502
assert (sargs <> []);
3503+
let position = apply_position env expected_mode sexp in
35033504
let funct_mode, funct_expected_mode =
3504-
match expected_mode.position with
3505+
match position with
35053506
| Tail ->
35063507
let mode = Value_mode.local_to_regional (Value_mode.newvar ()) in
35073508
mode, mode_tailcall_function mode
3508-
| Nontail ->
3509+
| Nontail | Default ->
35093510
let mode = Value_mode.newvar () in
35103511
mode, mode_nontail mode
35113512
in
@@ -3554,7 +3555,6 @@ and type_expect_
35543555
| _ ->
35553556
funct, sargs
35563557
in
3557-
let position = apply_position env expected_mode sexp in
35583558
begin_def ();
35593559
let (args, ty_res, position) =
35603560
type_application env loc expected_mode position funct funct_mode sargs

0 commit comments

Comments
 (0)