diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2018-09-03 17:51:30 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-09-03 17:51:30 +0200 |
commit | 1a60ffcf1dc265c6b92dfd757e1bfd5e904c1f3d (patch) | |
tree | 2f70738c3379cc3fc54d2f56bb6d9a20ea09488d /compiler/jsgen.nim | |
parent | 0694c9080f85b59e86ddfb0bd3c799fe9d9e30ae (diff) | |
download | Nim-1a60ffcf1dc265c6b92dfd757e1bfd5e904c1f3d.tar.gz |
Correctly mangle `this` in the JS backend (#8853)
As shown in pragmagic/karax#67 using `this` as parameter name made the codegen output wrong code (and the user didn't notice the errors in the browser console).
Diffstat (limited to 'compiler/jsgen.nim')
-rw-r--r-- | compiler/jsgen.nim | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index b9b22d825..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: |