summary refs log tree commit diff stats
path: root/tests/js/trefbyvar.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-05-28 12:50:46 +0200
committerAraq <rumpf_a@web.de>2015-05-28 12:51:18 +0200
commit8d508162e88aff8b86b7320c1d84de129692a401 (patch)
tree07b622f3ee58c3e9ee30a57177c6aaebb61da9ab /tests/js/trefbyvar.nim
parent543ec379755879af7fe543d7b4596a9646d60a92 (diff)
downloadNim-8d508162e88aff8b86b7320c1d84de129692a401.tar.gz
added missing test
Diffstat (limited to 'tests/js/trefbyvar.nim')
-rw-r--r--tests/js/trefbyvar.nim35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/js/trefbyvar.nim b/tests/js/trefbyvar.nim
new file mode 100644
index 000000000..68dd36543
--- /dev/null
+++ b/tests/js/trefbyvar.nim
@@ -0,0 +1,35 @@
+discard """
+  output: '''0
+5
+0
+5'''
+"""
+
+# bug #2476
+
+type A = ref object
+    m: int
+
+proc f(a: var A) =
+    var b: A
+    b.new()
+    b.m = 5
+    a = b
+
+var t: A
+t.new()
+
+echo t.m
+t.f()
+echo t.m
+
+proc main =
+  # now test the same for locals
+  var t: A
+  t.new()
+
+  echo t.m
+  t.f()
+  echo t.m
+
+main()