summary refs log tree commit diff stats
path: root/compiler/jsgen.nim
diff options
context:
space:
mode:
authorawr1 <41453959+awr1@users.noreply.github.com>2018-09-04 16:33:52 -0500
committerGitHub <noreply@github.com>2018-09-04 16:33:52 -0500
commiteb668003bf35671d7358e5f54e05820c0f4aef3d (patch)
treee5c5d6315f8ba4a5dd647bf67a4d0afb609916e7 /compiler/jsgen.nim
parent89ad1cc9b18db8320e5b170ee45888cf79d52001 (diff)
parent4aba2981dd47672744191bd17b39bb149f494637 (diff)
downloadNim-eb668003bf35671d7358e5f54e05820c0f4aef3d.tar.gz
Merge branch 'devel' into experimentalize-reorder
Diffstat (limited to 'compiler/jsgen.nim')
-rw-r--r--compiler/jsgen.nim9
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 462c622aa..1b00ddbfa 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -243,7 +243,8 @@ proc mangleName(m: BModule, s: PSym): Rope =
           x.add("HEX" & toHex(ord(c), 2))
         inc i
       result = rope(x)
-    if s.name.s != "this" and s.kind != skField:
+    # From ES5 on reserved words can be used as object field names
+    if s.kind != skField:
       if optHotCodeReloading in m.config.options:
         # When hot reloading is enabled, we must ensure that the names
         # of functions and types will be preserved across rebuilds:
@@ -271,9 +272,7 @@ proc escapeJSString(s: string): string =
   result.add("\"")
 
 proc makeJSString(s: string, escapeNonAscii = true): Rope =
-  if s.isNil:
-    result = "null".rope
-  elif escapeNonAscii:
+  if escapeNonAscii:
     result = strutils.escape(s).rope
   else:
     result = escapeJSString(s).rope
@@ -1369,7 +1368,7 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope =
     let length = int(lengthOrd(p.config, t))
     let e = elemType(t)
     let jsTyp = arrayTypeForElemType(e)
-    if not jsTyp.isNil:
+    if jsTyp.len > 0:
       result = "new $1($2)" % [rope(jsTyp), rope(length)]
     elif length > 32:
       useMagic(p, "arrayConstr")