Skip to content

Commit 92fd9b7

Browse files
tonowakmshinwell
authored andcommitted
Pass Uid a bit further to loops and add comments when we stop passing it
1 parent ded2ee0 commit 92fd9b7

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

ocaml/typing/typecore.ml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,8 @@ let split_cases env cases =
15971597
so [enter_variable] can be called, depending on the usage. *)
15981598
let type_for_loop_like_index ~error ~loc ~env ~param ~any ~var =
15991599
match param.ppat_desc with
1600-
| Ppat_any -> any (Ident.create_local "_for")
1600+
| Ppat_any ->
1601+
any (Ident.create_local "_for", Uid.mk ~current_unit:(Env.get_unit_name ()))
16011602
| Ppat_var name ->
16021603
var ~name
16031604
~pv_mode:Value.min_mode
@@ -1630,7 +1631,7 @@ let type_for_loop_index ~loc ~env ~param =
16301631
let pv =
16311632
{ pv_id; pv_uid; pv_mode; pv_type; pv_loc; pv_as_var; pv_attributes }
16321633
in
1633-
pv_id, add_pattern_variables ~check ~check_as:check env [pv])
1634+
(pv_id, pv_uid), add_pattern_variables ~check ~check_as:check env [pv])
16341635

16351636
let type_comprehension_for_range_iterator_index ~loc ~env ~param tps =
16361637
type_for_loop_like_index
@@ -1643,16 +1644,14 @@ let type_comprehension_for_range_iterator_index ~loc ~env ~param tps =
16431644
for duplicates or anything else. *)
16441645
~any:Fun.id
16451646
~var:(fun ~name ~pv_mode ~pv_type ~pv_loc ~pv_as_var ~pv_attributes ->
1646-
(* CR tnowak: verify this change *)
1647-
fst (
1648-
enter_variable
1649-
~is_as_variable:pv_as_var
1650-
tps
1651-
pv_loc
1652-
name
1653-
pv_mode
1654-
pv_type
1655-
pv_attributes))
1647+
enter_variable
1648+
~is_as_variable:pv_as_var
1649+
tps
1650+
pv_loc
1651+
name
1652+
pv_mode
1653+
pv_type
1654+
pv_attributes)
16561655

16571656

16581657
(* Type paths *)
@@ -5347,7 +5346,8 @@ and type_expect_
53475346
(mk_expected ~explanation:For_loop_stop_index Predef.type_int)
53485347
in
53495348
let env = Env.add_share_lock For_loop env in
5350-
let for_id, new_env =
5349+
(* When we'll want to add Uid to for loops, we can take it from here. *)
5350+
let (for_id, _for_uid), new_env =
53515351
type_for_loop_index ~loc ~env ~param
53525352
in
53535353
let new_env = Env.add_region_lock new_env in
@@ -8115,7 +8115,9 @@ and type_comprehension_iterator
81158115
in
81168116
let start = tbound ~explanation:Comprehension_for_start start in
81178117
let stop = tbound ~explanation:Comprehension_for_stop stop in
8118-
let ident =
8118+
(* When we'll want to add Uid to comprehension bindings,
8119+
we can take it from here. *)
8120+
let (ident, _uid) =
81198121
type_comprehension_for_range_iterator_index
81208122
tps
81218123
~loc

0 commit comments

Comments
 (0)