mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-28 10:13:56 +00:00
fixes #5269
This commit is contained in:
30
tests/vm/tcopy_global_var.nim
Normal file
30
tests/vm/tcopy_global_var.nim
Normal file
@@ -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"
|
||||
Reference in New Issue
Block a user