Skip to content

Commit 02c12f1

Browse files
committed
simplify
1 parent 81b11ec commit 02c12f1

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

jscomp/ml/typecore.ml

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ module NameChoice(Name : sig
790790
val get_type: t -> type_expr
791791
val get_descrs: Env.type_descriptions -> t list
792792

793-
val unsafe_do_not_use_add_with_name: t -> string -> t
793+
val unsafe_do_not_use__add_with_name: t -> string -> t
794794
val unbound_name_error: Env.t -> Longident.t loc -> 'a
795795

796796
end) = struct
@@ -807,21 +807,9 @@ end) = struct
807807
if Path.same tpath Predef.path_dict then (
808808
(* [dict] Handle directing any label lookup to the magic dict field. *)
809809
match lid.txt with
810-
Longident.Lident s_ -> begin
811-
let s =
812-
if List.exists (fun nd -> get_name nd = s_) descrs
813-
|| not (List.exists (fun nd -> get_name nd = Dict_type_helpers.dict_magic_field_name) descrs)
814-
then s_
815-
else Dict_type_helpers.dict_magic_field_name in
816-
try
817-
let x = List.find (fun nd -> get_name nd = s) descrs in
818-
if s = Dict_type_helpers.dict_magic_field_name
819-
then unsafe_do_not_use_add_with_name x s_
820-
else x
821-
with Not_found ->
822-
let names = List.map get_name descrs in
823-
raise (Error (lid.loc, env,
824-
Wrong_name ("", newvar (), type_kind, tpath, s, names)))
810+
Longident.Lident s -> begin
811+
let x = List.find (fun nd -> get_name nd = Dict_type_helpers.dict_magic_field_name) descrs in
812+
unsafe_do_not_use__add_with_name x s
825813
end
826814
| _ -> raise Not_found)
827815
else match lid.txt with
@@ -908,7 +896,7 @@ module Label = NameChoice (struct
908896
let type_kind = "record"
909897
let get_name lbl = lbl.lbl_name
910898

911-
let unsafe_do_not_use_add_with_name lbl name =
899+
let unsafe_do_not_use__add_with_name lbl name =
912900
(* [dict] This is used in dicts and shouldn't be used anywhere else.
913901
It adds a new field to an existing record type, to "fool" the pattern
914902
matching into thinking the label exists. *)
@@ -1078,7 +1066,7 @@ module Constructor = NameChoice (struct
10781066
let get_name cstr = cstr.cstr_name
10791067
let get_type cstr = cstr.cstr_res
10801068

1081-
let unsafe_do_not_use_add_with_name _cstr _name = assert false
1069+
let unsafe_do_not_use__add_with_name _cstr _name = assert false
10821070
let get_descrs = fst
10831071
let unbound_name_error = Typetexp.unbound_constructor_error
10841072
end)

0 commit comments

Comments
 (0)