Skip to content

Commit 50d1e1d

Browse files
committed
Add question mark and ampersand to special chars
1 parent 149b584 commit 50d1e1d

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

jscomp/ext/ext_ident.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ let js_module_table : Ident.t String_hashtbl.t = String_hashtbl.create 31
7979
*)
8080
let create_js_module (name : string) : Ident.t =
8181
let name =
82-
String.concat "" @@ Ext_list.map
82+
String.concat "" @@ Ext_list.map
8383
(Ext_string.split name '-') Ext_string.capitalize_ascii in
8484
(* TODO: if we do such transformation, we should avoid collision for example:
8585
react-dom
@@ -136,6 +136,8 @@ let name_mangle name =
136136
| '~' -> Buffer.add_string buffer "$tilde"
137137
| '#' -> Buffer.add_string buffer "$hash"
138138
| ':' -> Buffer.add_string buffer "$colon"
139+
| '?' -> Buffer.add_string buffer "$question"
140+
| '&' -> Buffer.add_string buffer "$amp"
139141
| 'a'..'z' | 'A'..'Z'| '_'
140142
| '$'
141143
| '0'..'9'-> Buffer.add_char buffer c
@@ -165,6 +167,8 @@ let name_mangle name =
165167
| '~' -> Buffer.add_string buffer "$tilde"
166168
| '#' -> Buffer.add_string buffer "$hash"
167169
| ':' -> Buffer.add_string buffer "$colon"
170+
| '?' -> Buffer.add_string buffer "$question"
171+
| '&' -> Buffer.add_string buffer "$amp"
168172
| '$' -> Buffer.add_string buffer "$dollar"
169173
| 'a'..'z' | 'A'..'Z'| '_'
170174
| '0'..'9'-> Buffer.add_char buffer c
@@ -181,7 +185,7 @@ let name_mangle name =
181185
a valid js identifier
182186
*)
183187
let convert (name : string) =
184-
if Js_reserved_map.is_reserved name then
188+
if Js_reserved_map.is_reserved name then
185189
"$$" ^ name
186190
else name_mangle name
187191

@@ -212,4 +216,3 @@ let compare (x : Ident.t ) ( y : Ident.t) =
212216
let equal ( x : Ident.t) ( y : Ident.t) =
213217
if x.stamp <> 0 then x.stamp = y.stamp
214218
else y.stamp = 0 && x.name = y.name
215-

lib/4.02.3/unstable/all_ounit_tests.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11692,7 +11692,7 @@ let js_module_table : Ident.t String_hashtbl.t = String_hashtbl.create 31
1169211692
*)
1169311693
let create_js_module (name : string) : Ident.t =
1169411694
let name =
11695-
String.concat "" @@ Ext_list.map
11695+
String.concat "" @@ Ext_list.map
1169611696
(Ext_string.split name '-') Ext_string.capitalize_ascii in
1169711697
(* TODO: if we do such transformation, we should avoid collision for example:
1169811698
react-dom
@@ -11749,6 +11749,8 @@ let name_mangle name =
1174911749
| '~' -> Buffer.add_string buffer "$tilde"
1175011750
| '#' -> Buffer.add_string buffer "$hash"
1175111751
| ':' -> Buffer.add_string buffer "$colon"
11752+
| '?' -> Buffer.add_string buffer "$question"
11753+
| '&' -> Buffer.add_string buffer "$amp"
1175211754
| 'a'..'z' | 'A'..'Z'| '_'
1175311755
| '$'
1175411756
| '0'..'9'-> Buffer.add_char buffer c
@@ -11778,6 +11780,8 @@ let name_mangle name =
1177811780
| '~' -> Buffer.add_string buffer "$tilde"
1177911781
| '#' -> Buffer.add_string buffer "$hash"
1178011782
| ':' -> Buffer.add_string buffer "$colon"
11783+
| '?' -> Buffer.add_string buffer "$question"
11784+
| '&' -> Buffer.add_string buffer "$amp"
1178111785
| '$' -> Buffer.add_string buffer "$dollar"
1178211786
| 'a'..'z' | 'A'..'Z'| '_'
1178311787
| '0'..'9'-> Buffer.add_char buffer c
@@ -11794,7 +11798,7 @@ let name_mangle name =
1179411798
a valid js identifier
1179511799
*)
1179611800
let convert (name : string) =
11797-
if Js_reserved_map.is_reserved name then
11801+
if Js_reserved_map.is_reserved name then
1179811802
"$$" ^ name
1179911803
else name_mangle name
1180011804

@@ -11826,7 +11830,6 @@ let equal ( x : Ident.t) ( y : Ident.t) =
1182611830
if x.stamp <> 0 then x.stamp = y.stamp
1182711831
else y.stamp = 0 && x.name = y.name
1182811832

11829-
1183011833
end
1183111834
module Hash_set_ident_mask : sig
1183211835
#1 "hash_set_ident_mask.mli"

lib/4.02.3/unstable/js_compiler.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77801,7 +77801,7 @@ let js_module_table : Ident.t String_hashtbl.t = String_hashtbl.create 31
7780177801
*)
7780277802
let create_js_module (name : string) : Ident.t =
7780377803
let name =
77804-
String.concat "" @@ Ext_list.map
77804+
String.concat "" @@ Ext_list.map
7780577805
(Ext_string.split name '-') Ext_string.capitalize_ascii in
7780677806
(* TODO: if we do such transformation, we should avoid collision for example:
7780777807
react-dom
@@ -77858,6 +77858,8 @@ let name_mangle name =
7785877858
| '~' -> Buffer.add_string buffer "$tilde"
7785977859
| '#' -> Buffer.add_string buffer "$hash"
7786077860
| ':' -> Buffer.add_string buffer "$colon"
77861+
| '?' -> Buffer.add_string buffer "$question"
77862+
| '&' -> Buffer.add_string buffer "$amp"
7786177863
| 'a'..'z' | 'A'..'Z'| '_'
7786277864
| '$'
7786377865
| '0'..'9'-> Buffer.add_char buffer c
@@ -77887,6 +77889,8 @@ let name_mangle name =
7788777889
| '~' -> Buffer.add_string buffer "$tilde"
7788877890
| '#' -> Buffer.add_string buffer "$hash"
7788977891
| ':' -> Buffer.add_string buffer "$colon"
77892+
| '?' -> Buffer.add_string buffer "$question"
77893+
| '&' -> Buffer.add_string buffer "$amp"
7789077894
| '$' -> Buffer.add_string buffer "$dollar"
7789177895
| 'a'..'z' | 'A'..'Z'| '_'
7789277896
| '0'..'9'-> Buffer.add_char buffer c
@@ -77903,7 +77907,7 @@ let name_mangle name =
7790377907
a valid js identifier
7790477908
*)
7790577909
let convert (name : string) =
77906-
if Js_reserved_map.is_reserved name then
77910+
if Js_reserved_map.is_reserved name then
7790777911
"$$" ^ name
7790877912
else name_mangle name
7790977913

@@ -77935,7 +77939,6 @@ let equal ( x : Ident.t) ( y : Ident.t) =
7793577939
if x.stamp <> 0 then x.stamp = y.stamp
7793677940
else y.stamp = 0 && x.name = y.name
7793777941

77938-
7793977942
end
7794077943
module Set_gen
7794177944
= struct

lib/4.02.3/whole_compiler.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68966,7 +68966,7 @@ let js_module_table : Ident.t String_hashtbl.t = String_hashtbl.create 31
6896668966
*)
6896768967
let create_js_module (name : string) : Ident.t =
6896868968
let name =
68969-
String.concat "" @@ Ext_list.map
68969+
String.concat "" @@ Ext_list.map
6897068970
(Ext_string.split name '-') Ext_string.capitalize_ascii in
6897168971
(* TODO: if we do such transformation, we should avoid collision for example:
6897268972
react-dom
@@ -69023,6 +69023,8 @@ let name_mangle name =
6902369023
| '~' -> Buffer.add_string buffer "$tilde"
6902469024
| '#' -> Buffer.add_string buffer "$hash"
6902569025
| ':' -> Buffer.add_string buffer "$colon"
69026+
| '?' -> Buffer.add_string buffer "$question"
69027+
| '&' -> Buffer.add_string buffer "$amp"
6902669028
| 'a'..'z' | 'A'..'Z'| '_'
6902769029
| '$'
6902869030
| '0'..'9'-> Buffer.add_char buffer c
@@ -69052,6 +69054,8 @@ let name_mangle name =
6905269054
| '~' -> Buffer.add_string buffer "$tilde"
6905369055
| '#' -> Buffer.add_string buffer "$hash"
6905469056
| ':' -> Buffer.add_string buffer "$colon"
69057+
| '?' -> Buffer.add_string buffer "$question"
69058+
| '&' -> Buffer.add_string buffer "$amp"
6905569059
| '$' -> Buffer.add_string buffer "$dollar"
6905669060
| 'a'..'z' | 'A'..'Z'| '_'
6905769061
| '0'..'9'-> Buffer.add_char buffer c
@@ -69068,7 +69072,7 @@ let name_mangle name =
6906869072
a valid js identifier
6906969073
*)
6907069074
let convert (name : string) =
69071-
if Js_reserved_map.is_reserved name then
69075+
if Js_reserved_map.is_reserved name then
6907269076
"$$" ^ name
6907369077
else name_mangle name
6907469078

@@ -69100,7 +69104,6 @@ let equal ( x : Ident.t) ( y : Ident.t) =
6910069104
if x.stamp <> 0 then x.stamp = y.stamp
6910169105
else y.stamp = 0 && x.name = y.name
6910269106

69103-
6910469107
end
6910569108
module Set_gen
6910669109
= struct

0 commit comments

Comments
 (0)