Skip to content

Commit e0e62fc

Browse files
committed
Typecheck x |> f y as (f y x), not ((f y) x)
1 parent d7e34ce commit e0e62fc

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

testsuite/tests/typing-misc/printing.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ and bar () =
110110
let x = foo () in
111111
x |> List.fold_left max 0 x
112112
[%%expect {|
113-
Line 4, characters 7-29:
113+
Line 4, characters 26-27:
114114
4 | x |> List.fold_left max 0 x
115-
^^^^^^^^^^^^^^^^^^^^^^
116-
Error: This expression has type int
117-
This is not a function; it cannot be applied.
115+
^
116+
Error: This expression has type int but an expression was expected of type
117+
'a -> 'b
118118
|}]

typing/typecore.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3498,18 +3498,25 @@ and type_expect_
34983498
wrap_trace_gadt_instances env (lower_args []) ty;
34993499
funct
35003500
in
3501+
let type_sfunct_args sfunct extra_args =
3502+
match sfunct.pexp_desc with
3503+
| Pexp_apply (sfunct, args) ->
3504+
type_sfunct sfunct, args @ extra_args
3505+
| _ ->
3506+
type_sfunct sfunct, extra_args
3507+
in
35013508
let funct, sargs =
35023509
let funct = type_sfunct sfunct in
35033510
match funct.exp_desc, sargs with
35043511
| Texp_ident (_, _, {val_kind = Val_prim {prim_name = "%revapply"}},
35053512
Id_prim _),
35063513
[Nolabel, sarg; Nolabel, actual_sfunct]
35073514
when is_inferred actual_sfunct ->
3508-
type_sfunct actual_sfunct, [Nolabel, sarg]
3515+
type_sfunct_args actual_sfunct [Nolabel, sarg]
35093516
| Texp_ident (_, _, {val_kind = Val_prim {prim_name = "%apply"}},
35103517
Id_prim _),
35113518
[Nolabel, actual_sfunct; Nolabel, sarg] ->
3512-
type_sfunct actual_sfunct, [Nolabel, sarg]
3519+
type_sfunct_args actual_sfunct [Nolabel, sarg]
35133520
| _ ->
35143521
funct, sargs
35153522
in

0 commit comments

Comments
 (0)