diff --git a/compiler/vm.nim b/compiler/vm.nim index 34caec83fe..27b067da22 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -401,7 +401,7 @@ proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType): else: internalError(c.config, "cannot convert to string " & desttyp.typeToString) else: - case skipTypes(desttyp, abstractRange).kind + case skipTypes(desttyp, abstractVarRange).kind of tyInt..tyInt64: if 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: dest.floatVal = src.floatVal of tyObject: - if srctyp.skipTypes(abstractRange).kind != tyObject: + if srctyp.skipTypes(abstractVarRange).kind != tyObject: internalError(c.config, "invalid object-to-object conversion") # A object-to-object conversion is essentially a no-op moveConst(dest, src) diff --git a/tests/vm/tconstobj.nim b/tests/vm/tconstobj.nim index 3cf256eedf..ac7148b59c 100644 --- a/tests/vm/tconstobj.nim +++ b/tests/vm/tconstobj.nim @@ -65,3 +65,8 @@ static: initBase(SomeBaseObj(ifb2)) echo repr(ifb2) doAssert(ifb2.txt == "Initialized string from base") + +static: # issue #11861 + var ifb2: InheritedFromBase + initBase(ifb2) + doAssert(ifb2.txt == "Initialized string from base")