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).
This commit is contained in:
parent
0694c9080f
commit
1a60ffcf1d
3 changed files with 27 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue