summary refs log tree commit diff stats
path: root/tests/js
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2020-07-28 03:13:49 +0800
committerGitHub <noreply@github.com>2020-07-27 21:13:49 +0200
commitcac09a43aea0e8bcc6a7f2634cfcd4274a260b49 (patch)
tree556c72495802756b0d98fbe7cefd0ae552cda475 /tests/js
parent191c388792c1b57c3855e9c3b9c83293be8a6207 (diff)
downloadNim-cac09a43aea0e8bcc6a7f2634cfcd4274a260b49.tar.gz
fix #11354 jsgen not carefully handle genAddr with nkHiddenAddr,nkStm… (#15078)
* fix #11354 jsgen not carefully handle genAddr with nkHiddenAddr,nkStmtListExpr; genAsgn with lvalue tyVar and rvalue tyPtr

* correct logic

* add test for #11354

* handle nkHiddenAddr when n.len == 1

* Update compiler/jsgen.nim

* Update compiler/jsgen.nim

* Apply suggestions from code review

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'tests/js')
-rw-r--r--tests/js/t11354.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/js/t11354.nim b/tests/js/t11354.nim
new file mode 100644
index 000000000..8dee90de0
--- /dev/null
+++ b/tests/js/t11354.nim
@@ -0,0 +1,20 @@
+discard """
+  output: '''
+0
+@[@[0, 1]]
+'''
+"""
+
+type
+  TrackySeq[T] = object
+    s: seq[T]
+    pos: int
+
+proc foobar(ls: var TrackySeq[seq[int]], i: int): var seq[int] =
+  echo ls.pos  # removing this, or making the return explicit works
+  ls.s[i]
+
+var foo: TrackySeq[seq[int]]
+foo.s.add(@[0])
+foo.foobar(0).add(1)
+echo foo.s
\ No newline at end of file