Skip to content

Commit 61c8d95

Browse files
committed
fix reserved words
1 parent fcdf7a9 commit 61c8d95

34 files changed

+547
-1818
lines changed

jscomp/ext/ext_ident.ml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26-
27-
28-
29-
30-
31-
3226
let js_flag = 0b1_000 (* check with ocaml compiler *)
3327

3428
(* let js_module_flag = 0b10_000 (\* javascript external modules *\) *)
@@ -172,18 +166,14 @@ let name_mangle name =
172166
Ext_buffer.add_string buffer (convert ~op:(i=0) c)
173167
done; Ext_buffer.contents buffer
174168

175-
(* TODO:
176-
check name conflicts with javascript conventions
177-
{[
178-
Ext_ident.convert "^";;
179-
- : string = "$caret"
180-
]}
181-
[convert name] if [name] is a js keyword,add "$$"
169+
(**
170+
[convert name] if [name] is a js keyword or js global, add "$$"
182171
otherwise do the name mangling to make sure ocaml identifier it is
183172
a valid js identifier
184173
*)
185174
let convert (name : string) =
186-
if Js_reserved_map.is_reserved name then
175+
let name = unwrap_uppercase_exotic name in
176+
if Js_reserved_map.is_js_keyword name || Js_reserved_map.is_js_global name then
187177
"$$" ^ name
188178
else name_mangle name
189179

0 commit comments

Comments
 (0)