diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2019-01-22 07:36:40 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-01-22 07:36:40 +0100 |
commit | 44c04b35717336595dad03ac532ee9e141a0e374 (patch) | |
tree | ddadd6cfc49d1d5bef8b5b77508613efeb9c04a9 /tests | |
parent | 3ea099bc7f75d35ee127932208d9d012b57f11f8 (diff) | |
download | Nim-44c04b35717336595dad03ac532ee9e141a0e374.tar.gz |
Object downconversion in VM should not copy (#10378)
Hopefully the type-check phase already rejected all the invalid conversions by the time we execute the VM bytecode. Problem reported by chrisheller on the Nim Forum
Diffstat (limited to 'tests')
-rw-r--r-- | tests/vm/tconstobj.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/vm/tconstobj.nim b/tests/vm/tconstobj.nim index 021fcb728..3cf256eed 100644 --- a/tests/vm/tconstobj.nim +++ b/tests/vm/tconstobj.nim @@ -48,3 +48,20 @@ let people = { }.toTable() echo people["001"] + +# Object downconversion should not copy + +type + SomeBaseObj {.inheritable.} = object of RootObj + txt : string + InheritedFromBase = object of SomeBaseObj + other : string + +proc initBase(sbo: var SomeBaseObj) = + sbo.txt = "Initialized string from base" + +static: + var ifb2: InheritedFromBase + initBase(SomeBaseObj(ifb2)) + echo repr(ifb2) + doAssert(ifb2.txt == "Initialized string from base") |