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
This commit is contained in:
LemonBoy 2019-01-22 07:36:40 +01:00 • committed by Andreas Rumpf
commit 44c04b3571
2 changed files with 22 additions and 0 deletions

View file

@ -399,6 +399,11 @@ proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType):
dest.floatVal = toBiggestFloat(src.intVal)
else:
dest.floatVal = src.floatVal
of tyObject:
if srctyp.skipTypes(abstractRange).kind != tyObject:
internalError(c.config, "invalid object-to-object conversion")
# A object-to-object conversion is essentially a no-op
moveConst(dest, src)
else:
asgnComplex(dest, src)