Skip to content

Commit

Permalink
Pass Uid a bit further to loops and add comments when we stop passing it
Browse files Browse the repository at this point in the history
  • Loading branch information
tonowak committed Aug 30, 2023
1 parent a39546d commit 982ab55
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions ocaml/typing/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,8 @@ let split_cases env cases =
so [enter_variable] can be called, depending on the usage. *)
let type_for_loop_like_index ~error ~loc ~env ~param ~any ~var =
match param.ppat_desc with
| Ppat_any -> any (Ident.create_local "_for")
| Ppat_any ->
any (Ident.create_local "_for", Uid.mk ~current_unit:(Env.get_unit_name ()))
| Ppat_var name ->
var ~name
~pv_mode:Value_mode.global
Expand Down Expand Up @@ -1480,7 +1481,7 @@ let type_for_loop_index ~loc ~env ~param =
let pv =
{ pv_id; pv_uid; pv_mode; pv_type; pv_loc; pv_as_var; pv_attributes }
in
pv_id, add_pattern_variables ~check ~check_as:check env [pv])
(pv_id, pv_uid), add_pattern_variables ~check ~check_as:check env [pv])

let type_comprehension_for_range_iterator_index ~loc ~env ~param tps =
type_for_loop_like_index
Expand All @@ -1493,16 +1494,14 @@ let type_comprehension_for_range_iterator_index ~loc ~env ~param tps =
for duplicates or anything else. *)
~any:Fun.id
~var:(fun ~name ~pv_mode ~pv_type ~pv_loc ~pv_as_var ~pv_attributes ->
(* CR tnowak: verify this change *)
fst (
enter_variable
~is_as_variable:pv_as_var
tps
pv_loc
name
pv_mode
pv_type
pv_attributes))
enter_variable
~is_as_variable:pv_as_var
tps
pv_loc
name
pv_mode
pv_type
pv_attributes)


(* Type paths *)
Expand Down Expand Up @@ -5012,7 +5011,8 @@ and type_expect_
type_expect env (mode_region Value_mode.local) shigh
(mk_expected ~explanation:For_loop_stop_index Predef.type_int)
in
let for_id, new_env =
(* When we'll want to add Uid to for loops, we can take it from here. *)
let (for_id, _for_uid), new_env =
type_for_loop_index ~loc ~env ~param
in
let new_env = Env.add_region_lock new_env in
Expand Down Expand Up @@ -7658,7 +7658,9 @@ and type_comprehension_iterator
in
let start = tbound ~explanation:Comprehension_for_start start in
let stop = tbound ~explanation:Comprehension_for_stop stop in
let ident =
(* When we'll want to add Uid to comprehension bindings,
we can take it from here. *)
let (ident, _uid) =
type_comprehension_for_range_iterator_index
tps
~loc
Expand Down

0 comments on commit 982ab55

Please sign in to comment.