File tree 3 files changed +22
-1
lines changed
testsuite/tests/typing-layouts
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -72,3 +72,17 @@ let evaluate =
72
72
let _ =
73
73
Printf. printf " \" real\" code (3.14): %.2f\n "
74
74
(box_float (evaluate [|2 ; 3 ; 4 |] ~size: 1 ))
75
+
76
+ (* Omitting optional arg, where let binding is needed for function. *)
77
+ module M = struct
78
+ (* Putting this in a module defeats an optimization in simplif that removes an
79
+ intermediate let binding where the bug occurs (it reduces [let x = y in
80
+ ...], but only if [y] is precisely a variable, which a projection from a
81
+ module is not). *)
82
+ let to_string ?(explicit_plus = false ) x =
83
+ if explicit_plus then " blah" else string_of_float (box_float x)
84
+ end
85
+
86
+ let pi_to_string ~value_to_string = value_to_string #3.14
87
+ let pi = pi_to_string ~value_to_string: M. to_string
88
+ let () = Printf. printf " Omitting optional arg (3.14): %s\n " pi
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ Omitting named arg (6.29): 6.29
2
2
Omitting named arg (6.27): 6.27
3
3
Omitting named arg (9.42): 9.42
4
4
"real" code (3.14): 3.14
5
+ Omitting optional arg (3.14): 3.14
Original file line number Diff line number Diff line change @@ -8146,10 +8146,16 @@ and type_argument ?explanation ?recarg ~overwrite env (mode : expected_mode) sar
8146
8146
(Warnings. Non_principal_labels " eliminated omittable argument" );
8147
8147
(* let-expand to have side effects *)
8148
8148
let let_pat, let_var = var_pair ~mode: exp_mode " arg" texp.exp_type in
8149
+ let let_pat_sort =
8150
+ (* The sort of the let-bound variable, which here is always a function
8151
+ (observe it is passed to [func], which builds an application of
8152
+ it). *)
8153
+ Jkind.Sort. value
8154
+ in
8149
8155
re { texp with exp_type = ty_fun;
8150
8156
exp_desc =
8151
8157
Texp_let (Nonrecursive ,
8152
- [{vb_pat= let_pat; vb_expr= texp; vb_sort= arg_sort ;
8158
+ [{vb_pat= let_pat; vb_expr= texp; vb_sort= let_pat_sort ;
8153
8159
vb_attributes= [] ; vb_loc= Location. none;
8154
8160
vb_rec_kind = Dynamic ;
8155
8161
}],
You can’t perform that action at this time.
0 commit comments