Fix VM conversion to var type [bugfix] (#11866)

This commit is contained in:
Oscar Nihlgård 2019-08-01 17:44:12 +02:00 • committed by Arne Döring
commit 829f719670
2 changed files with 7 additions and 2 deletions

View file

@ -401,7 +401,7 @@ proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType):
else: else:
internalError(c.config, "cannot convert to string " & desttyp.typeToString) internalError(c.config, "cannot convert to string " & desttyp.typeToString)
else: else:
case skipTypes(desttyp, abstractRange).kind case skipTypes(desttyp, abstractVarRange).kind
of tyInt..tyInt64: of tyInt..tyInt64:
if dest.kind != rkInt: if dest.kind != rkInt:
myreset(dest); dest.kind = rkInt myreset(dest); dest.kind = rkInt
@ -439,7 +439,7 @@ proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType):
else: else:
dest.floatVal = src.floatVal dest.floatVal = src.floatVal
of tyObject: of tyObject:
if srctyp.skipTypes(abstractRange).kind != tyObject: if srctyp.skipTypes(abstractVarRange).kind != tyObject:
internalError(c.config, "invalid object-to-object conversion") internalError(c.config, "invalid object-to-object conversion")
# A object-to-object conversion is essentially a no-op # A object-to-object conversion is essentially a no-op
moveConst(dest, src) moveConst(dest, src)

View file

@ -65,3 +65,8 @@ static:
initBase(SomeBaseObj(ifb2)) initBase(SomeBaseObj(ifb2))
echo repr(ifb2) echo repr(ifb2)
doAssert(ifb2.txt == "Initialized string from base") doAssert(ifb2.txt == "Initialized string from base")
static: # issue #11861
var ifb2: InheritedFromBase
initBase(ifb2)
doAssert(ifb2.txt == "Initialized string from base")