@@ -200,25 +200,24 @@ struct
200200 ; ori_name = get_name_index nm
201201 })
202202
203- let ident f = function
203+ let ident f ~ kind = function
204204 | S { name = Utf8 name ; var = Some v ; _ } ->
205- output_debug_info_ident f name (Code.Var. get_loc v);
205+ (match kind, Code.Var. get_name v with
206+ | `Binding , Some nm -> output_debug_info_ident f nm (Code.Var. get_loc v)
207+ | `Reference , _ | `Binding , None -> () );
206208 if false then PP. string f (Printf. sprintf " /* %d */" (Code.Var. idx v));
207209 PP. string f name
208- | S { name = Utf8 name ; var = None ; loc = Pi pi } ->
209- output_debug_info_ident f name (Some pi);
210- PP. string f name
211- | S { name = Utf8 name ; var = None ; loc = U | N } -> PP. string f name
210+ | S { name = Utf8 name ; var = None ; _ } -> PP. string f name
212211 | V v ->
213212 assert accept_unnamed_var;
214213 PP. string f (" <" ^ Code.Var. to_string v ^ " >" )
215214
216- let opt_identifier f i =
215+ let opt_identifier f ~ kind i =
217216 match i with
218217 | None -> ()
219218 | Some i ->
220219 PP. space f;
221- ident f i
220+ ident f ~kind i
222221
223222 let early_error _ = assert false
224223
@@ -578,7 +577,7 @@ struct
578577
579578 let rec expression (l : prec ) f e =
580579 match e with
581- | EVar v -> ident f v
580+ | EVar v -> ident f ~kind: `Reference v
582581 | ESeq (e1 , e2 ) ->
583582 if Prec. (l > Expression )
584583 then (
@@ -853,9 +852,9 @@ struct
853852 | EAssignTarget t -> (
854853 let property f p =
855854 match p with
856- | TargetPropertyId (Prop_and_ident id , None) -> ident f id
855+ | TargetPropertyId (Prop_and_ident id , None) -> ident f ~kind: `Reference id
857856 | TargetPropertyId (Prop_and_ident id , Some (e , _ )) ->
858- ident f id;
857+ ident f ~kind: `Reference id;
859858 PP. space f;
860859 PP. string f " =" ;
861860 PP. space f;
@@ -886,9 +885,9 @@ struct
886885 let element f p =
887886 match p with
888887 | TargetElementHole -> ()
889- | TargetElementId (id , None) -> ident f id
888+ | TargetElementId (id , None) -> ident f ~kind: `Reference id
890889 | TargetElementId (id , Some (e , _ )) ->
891- ident f id;
890+ ident f ~kind: `Reference id;
892891 PP. space f;
893892 PP. string f " =" ;
894893 PP. space f;
@@ -1185,11 +1184,11 @@ struct
11851184
11861185 and variable_declaration f ?(in_ = true ) x =
11871186 match x with
1188- | DeclIdent (i , None) -> ident f i
1187+ | DeclIdent (i , None) -> ident f ~kind: `Binding i
11891188 | DeclIdent (i , Some (e , loc )) ->
11901189 PP. start_group f 1 ;
11911190 PP. start_group f 0 ;
1192- ident f i;
1191+ ident f ~kind: `Binding i;
11931192 PP. space f;
11941193 PP. string f " =" ;
11951194 PP. end_group f;
@@ -1238,9 +1237,9 @@ struct
12381237 PP. string f " :" ;
12391238 PP. space f;
12401239 binding_element f e
1241- | Prop_ident (Prop_and_ident i , None) -> ident f i
1240+ | Prop_ident (Prop_and_ident i , None) -> ident f ~kind: `Binding i
12421241 | Prop_ident (Prop_and_ident i , Some (e , loc )) ->
1243- ident f i;
1242+ ident f ~kind: `Binding i;
12441243 PP. space f;
12451244 PP. string f " =" ;
12461245 PP. space f;
@@ -1260,7 +1259,7 @@ struct
12601259
12611260 and binding f x =
12621261 match x with
1263- | BindingIdent id -> ident f id
1262+ | BindingIdent id -> ident f ~kind: `Binding id
12641263 | BindingPattern p -> pattern f p
12651264
12661265 and binding_array_elt f x =
@@ -1278,7 +1277,7 @@ struct
12781277 ~force_last_comma: (fun _ -> false )
12791278 binding_property
12801279 list
1281- ident
1280+ ( ident ~kind: `Binding )
12821281 rest;
12831282 PP. string f " }" ;
12841283 PP. end_group f
@@ -1591,7 +1590,7 @@ struct
15911590 PP. start_group f 0 ;
15921591 PP. start_group f 0 ;
15931592 PP. string f " return function" ;
1594- opt_identifier f i;
1593+ opt_identifier f ~kind: `Binding i;
15951594 PP. end_group f;
15961595 PP. break f;
15971596 PP. start_group f 1 ;
@@ -1732,19 +1731,19 @@ struct
17321731 | SideEffect -> ()
17331732 | Default i ->
17341733 PP. space f;
1735- ident f i
1734+ ident f ~kind: `Binding i
17361735 | Namespace (def , i ) ->
17371736 Option. iter def ~f: (fun def ->
17381737 PP. space f;
1739- ident f def;
1738+ ident f ~kind: `Binding def;
17401739 PP. string f " ," );
17411740 PP. space f;
17421741 PP. string f " * as " ;
1743- ident f i
1742+ ident f ~kind: `Binding i
17441743 | Named (def , l ) ->
17451744 Option. iter def ~f: (fun def ->
17461745 PP. space f;
1747- ident f def;
1746+ ident f ~kind: `Binding def;
17481747 PP. string f " ," );
17491748 PP. space f;
17501749 PP. string f " {" ;
@@ -1756,11 +1755,11 @@ struct
17561755 if match i with
17571756 | S { name; _ } when Stdlib.Utf8_string. equal name s -> true
17581757 | _ -> false
1759- then ident f i
1758+ then ident f ~kind: `Binding i
17601759 else (
17611760 pp_ident_or_string_lit f s;
17621761 PP. string f " as " ;
1763- ident f i))
1762+ ident f ~kind: `Binding i))
17641763 l;
17651764 PP. space f;
17661765 PP. string f " }" );
@@ -1788,9 +1787,9 @@ struct
17881787 if match i with
17891788 | S { name; _ } when Stdlib.Utf8_string. equal name s -> true
17901789 | _ -> false
1791- then ident f i
1790+ then ident f ~kind: `Reference i
17921791 else (
1793- ident f i;
1792+ ident f ~kind: `Reference i;
17941793 PP. string f " as " ;
17951794 pp_ident_or_string_lit f s))
17961795 l;
@@ -1917,7 +1916,7 @@ struct
19171916 | { async = true ; generator = true } -> " async function*"
19181917 | { async = false ; generator = true } -> " function*"
19191918 in
1920- function_declaration f prefix ident name l b loc'
1919+ function_declaration f prefix ( ident ~kind: `Binding ) name l b loc'
19211920
19221921 and class_declaration f i x =
19231922 PP. start_group f 1 ;
@@ -1928,7 +1927,7 @@ struct
19281927 | None -> ()
19291928 | Some i ->
19301929 PP. space f;
1931- ident f i);
1930+ ident f ~kind: `Binding i);
19321931 PP. end_group f;
19331932 Option. iter x.extends ~f: (fun e ->
19341933 PP. space f;
0 commit comments