Skip to content

Commit b34adad

Browse files
committed
fix a regression in the namings
1 parent e5a1349 commit b34adad

File tree

4 files changed

+28
-24
lines changed

4 files changed

+28
-24
lines changed

jscomp/ext/ext_ident.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ let js_module_table : Ident.t Hash_string.t = Hash_string.create 31
9797
9898
*)
9999

100-
let [@inline] convert (c : char) : string =
100+
let [@inline] convert ?(op=false) (c : char) : string =
101101
(match c with
102102
| '*' -> "$star"
103103
| '\'' -> "$p"
@@ -106,7 +106,7 @@ let [@inline] convert (c : char) : string =
106106
| '<' -> "$less"
107107
| '=' -> "$eq"
108108
| '+' -> "$plus"
109-
| '-' -> "$neg"
109+
| '-' -> if op then "$neg" else "$"
110110
| '@' -> "$at"
111111
| '^' -> "$caret"
112112
| '/' -> "$slash"
@@ -131,23 +131,24 @@ let [@inline] no_escape (c : char) =
131131
| 'a' .. 'z' | 'A' .. 'Z'
132132
| '0' .. '9' | '_' | '$' -> true
133133
| _ -> false
134-
exception Not_normal_letter
134+
135+
exception Not_normal_letter of int
135136
let name_mangle name =
136137
let len = String.length name in
137138
try
138139
for i = 0 to len - 1 do
139140
if not (no_escape (String.unsafe_get name i)) then
140-
raise_notrace (Not_normal_letter )
141+
raise_notrace (Not_normal_letter i)
141142
done;
142143
name (* Normal letter *)
143144
with
144-
| Not_normal_letter ->
145+
| Not_normal_letter i ->
145146
let buffer = Ext_buffer.create len in
146147
for j = 0 to len - 1 do
147148
let c = String.unsafe_get name j in
148149
if no_escape c then Ext_buffer.add_char buffer c
149150
else
150-
Ext_buffer.add_string buffer (convert c)
151+
Ext_buffer.add_string buffer (convert ~op:(i=0) c)
151152
done; Ext_buffer.contents buffer
152153

153154
(* TODO:

lib/4.06.1/unstable/all_ounit_tests.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10932,7 +10932,7 @@ let js_module_table : Ident.t Hash_string.t = Hash_string.create 31
1093210932

1093310933
*)
1093410934

10935-
let [@inline] convert (c : char) : string =
10935+
let [@inline] convert ?(op=false) (c : char) : string =
1093610936
(match c with
1093710937
| '*' -> "$star"
1093810938
| '\'' -> "$p"
@@ -10941,7 +10941,7 @@ let [@inline] convert (c : char) : string =
1094110941
| '<' -> "$less"
1094210942
| '=' -> "$eq"
1094310943
| '+' -> "$plus"
10944-
| '-' -> "$neg"
10944+
| '-' -> if op then "$neg" else "$"
1094510945
| '@' -> "$at"
1094610946
| '^' -> "$caret"
1094710947
| '/' -> "$slash"
@@ -10966,23 +10966,24 @@ let [@inline] no_escape (c : char) =
1096610966
| 'a' .. 'z' | 'A' .. 'Z'
1096710967
| '0' .. '9' | '_' | '$' -> true
1096810968
| _ -> false
10969-
exception Not_normal_letter
10969+
10970+
exception Not_normal_letter of int
1097010971
let name_mangle name =
1097110972
let len = String.length name in
1097210973
try
1097310974
for i = 0 to len - 1 do
1097410975
if not (no_escape (String.unsafe_get name i)) then
10975-
raise_notrace (Not_normal_letter )
10976+
raise_notrace (Not_normal_letter i)
1097610977
done;
1097710978
name (* Normal letter *)
1097810979
with
10979-
| Not_normal_letter ->
10980+
| Not_normal_letter i ->
1098010981
let buffer = Ext_buffer.create len in
1098110982
for j = 0 to len - 1 do
1098210983
let c = String.unsafe_get name j in
1098310984
if no_escape c then Ext_buffer.add_char buffer c
1098410985
else
10985-
Ext_buffer.add_string buffer (convert c)
10986+
Ext_buffer.add_string buffer (convert ~op:(i=0) c)
1098610987
done; Ext_buffer.contents buffer
1098710988

1098810989
(* TODO:

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82022,7 +82022,7 @@ let js_module_table : Ident.t Hash_string.t = Hash_string.create 31
8202282022

8202382023
*)
8202482024

82025-
let [@inline] convert (c : char) : string =
82025+
let [@inline] convert ?(op=false) (c : char) : string =
8202682026
(match c with
8202782027
| '*' -> "$star"
8202882028
| '\'' -> "$p"
@@ -82031,7 +82031,7 @@ let [@inline] convert (c : char) : string =
8203182031
| '<' -> "$less"
8203282032
| '=' -> "$eq"
8203382033
| '+' -> "$plus"
82034-
| '-' -> "$neg"
82034+
| '-' -> if op then "$neg" else "$"
8203582035
| '@' -> "$at"
8203682036
| '^' -> "$caret"
8203782037
| '/' -> "$slash"
@@ -82056,23 +82056,24 @@ let [@inline] no_escape (c : char) =
8205682056
| 'a' .. 'z' | 'A' .. 'Z'
8205782057
| '0' .. '9' | '_' | '$' -> true
8205882058
| _ -> false
82059-
exception Not_normal_letter
82059+
82060+
exception Not_normal_letter of int
8206082061
let name_mangle name =
8206182062
let len = String.length name in
8206282063
try
8206382064
for i = 0 to len - 1 do
8206482065
if not (no_escape (String.unsafe_get name i)) then
82065-
raise_notrace (Not_normal_letter )
82066+
raise_notrace (Not_normal_letter i)
8206682067
done;
8206782068
name (* Normal letter *)
8206882069
with
82069-
| Not_normal_letter ->
82070+
| Not_normal_letter i ->
8207082071
let buffer = Ext_buffer.create len in
8207182072
for j = 0 to len - 1 do
8207282073
let c = String.unsafe_get name j in
8207382074
if no_escape c then Ext_buffer.add_char buffer c
8207482075
else
82075-
Ext_buffer.add_string buffer (convert c)
82076+
Ext_buffer.add_string buffer (convert ~op:(i=0) c)
8207682077
done; Ext_buffer.contents buffer
8207782078

8207882079
(* TODO:

lib/4.06.1/whole_compiler.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373278,7 +373278,7 @@ let js_module_table : Ident.t Hash_string.t = Hash_string.create 31
373278373278

373279373279
*)
373280373280

373281-
let [@inline] convert (c : char) : string =
373281+
let [@inline] convert ?(op=false) (c : char) : string =
373282373282
(match c with
373283373283
| '*' -> "$star"
373284373284
| '\'' -> "$p"
@@ -373287,7 +373287,7 @@ let [@inline] convert (c : char) : string =
373287373287
| '<' -> "$less"
373288373288
| '=' -> "$eq"
373289373289
| '+' -> "$plus"
373290-
| '-' -> "$neg"
373290+
| '-' -> if op then "$neg" else "$"
373291373291
| '@' -> "$at"
373292373292
| '^' -> "$caret"
373293373293
| '/' -> "$slash"
@@ -373312,23 +373312,24 @@ let [@inline] no_escape (c : char) =
373312373312
| 'a' .. 'z' | 'A' .. 'Z'
373313373313
| '0' .. '9' | '_' | '$' -> true
373314373314
| _ -> false
373315-
exception Not_normal_letter
373315+
373316+
exception Not_normal_letter of int
373316373317
let name_mangle name =
373317373318
let len = String.length name in
373318373319
try
373319373320
for i = 0 to len - 1 do
373320373321
if not (no_escape (String.unsafe_get name i)) then
373321-
raise_notrace (Not_normal_letter )
373322+
raise_notrace (Not_normal_letter i)
373322373323
done;
373323373324
name (* Normal letter *)
373324373325
with
373325-
| Not_normal_letter ->
373326+
| Not_normal_letter i ->
373326373327
let buffer = Ext_buffer.create len in
373327373328
for j = 0 to len - 1 do
373328373329
let c = String.unsafe_get name j in
373329373330
if no_escape c then Ext_buffer.add_char buffer c
373330373331
else
373331-
Ext_buffer.add_string buffer (convert c)
373332+
Ext_buffer.add_string buffer (convert ~op:(i=0) c)
373332373333
done; Ext_buffer.contents buffer
373333373334

373334373335
(* TODO:

0 commit comments

Comments
 (0)