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 /tests/js/tthismangle.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 'tests/js/tthismangle.nim')
-rw-r--r-- | tests/js/tthismangle.nim | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/js/tthismangle.nim b/tests/js/tthismangle.nim new file mode 100644 index 000000000..880abcc83 --- /dev/null +++ b/tests/js/tthismangle.nim @@ -0,0 +1,23 @@ +proc moo1(this: int) = + doAssert this == 42 + +proc moo2(x: int) = + var this = x + doAssert this == 42 + +proc moo3() = + for this in [1,1,1]: + doAssert this == 1 + +proc moo4() = + type + X = object + this: int + + var q = X(this: 42) + doAssert q.this == 42 + +moo1(42) +moo2(42) +moo3() +moo4() |