summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-02-05 08:51:35 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-02-05 08:51:43 +0100
commitc4dd9dc77e36eed0a71bf7b5d983d9de8e2e19e4 (patch)
treece0ab3753c0f7e4e569d2462dd1d82bd15fb2814 /tests
parent3978845266d154c9dba42a8d17266f057a52d90f (diff)
downloadNim-c4dd9dc77e36eed0a71bf7b5d983d9de8e2e19e4.tar.gz
fixes #5269
Diffstat (limited to 'tests')
-rw-r--r--tests/vm/tcopy_global_var.nim30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/vm/tcopy_global_var.nim b/tests/vm/tcopy_global_var.nim
new file mode 100644
index 000000000..eadd27b9a
--- /dev/null
+++ b/tests/vm/tcopy_global_var.nim
@@ -0,0 +1,30 @@
+discard """
+  nimout: "static done"
+"""
+
+# bug #5269
+
+proc assertEq[T](arg0, arg1: T): void =
+  assert arg0 == arg1, $arg0 & " == " & $arg1
+
+type
+  MyType = object
+    str: string
+    a: int
+
+block:
+  var localValue = MyType(str: "Original strning, (OK)", a: 0)
+  var valueCopy = localValue
+  valueCopy.a = 123
+  valueCopy.str = "Modified strning, (not OK when in localValue)"
+  assertEq(localValue.str, "Original strning, (OK)")
+  assertEq(localValue.a,   0)
+
+static:
+  var localValue = MyType(str: "Original strning, (OK)", a: 0)
+  var valueCopy = localValue
+  valueCopy.a = 123
+  valueCopy.str = "Modified strning, (not OK when in localValue)"
+  assertEq(localValue.str, "Original strning, (OK)")
+  assertEq(localValue.a,   0)
+  echo "static done"