Skip to content

Commit f925a62

Browse files
authored
Remove some uneeded mode variables (oxcaml#8)
1 parent dec721c commit f925a62

5 files changed

Lines changed: 11 additions & 4 deletions

File tree

boot/ocamlc

298 Bytes
Binary file not shown.

boot/ocamllex

0 Bytes
Binary file not shown.

typing/btype.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,13 @@ module Alloc_mode = struct
10741074

10751075
let newvar () = Amodevar (fresh ())
10761076

1077+
let newvar_below = function
1078+
| Amode Global -> Amode Global
1079+
| m ->
1080+
let v = newvar () in
1081+
submode_exn v m;
1082+
v
1083+
10771084
let check_const = function
10781085
| Amode m -> Some m
10791086
| Amodevar v ->

typing/btype.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ module Alloc_mode : sig
290290

291291
val newvar : unit -> t
292292

293+
val newvar_below : t -> t
294+
293295
val check_const : t -> const option
294296

295297
val print : Format.formatter -> t -> unit

typing/typecore.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5283,17 +5283,15 @@ and type_argument ?explanation ?recarg env (mode : expected_mode) sarg
52835283
and type_apply_arg env ~funct ~index ~position ~partial_app (lbl, arg) =
52845284
match arg with
52855285
| Arg (Unknown_arg { sarg; ty_arg; mode_arg }) ->
5286-
let mode = Alloc_mode.newvar () in
5287-
Alloc_mode.submode_exn mode mode_arg;
5286+
let mode = Alloc_mode.newvar_below mode_arg in
52885287
let expected_mode =
52895288
mode_argument ~funct ~index ~position ~partial_app mode in
52905289
let arg = type_expect env expected_mode sarg (mk_expected ty_arg) in
52915290
if is_optional lbl then
52925291
unify_exp env arg (type_option(newvar()));
52935292
(lbl, Arg arg)
52945293
| Arg (Known_arg { sarg; ty_arg; ty_arg0; mode_arg; wrapped_in_some }) ->
5295-
let mode = Alloc_mode.newvar () in
5296-
Alloc_mode.submode_exn mode mode_arg;
5294+
let mode = Alloc_mode.newvar_below mode_arg in
52975295
let expected_mode =
52985296
mode_argument ~funct ~index ~position ~partial_app mode in
52995297
let arg =

0 commit comments

Comments
 (0)