diff options
author | Oscar Nihlgård <oscarnihlgard@gmail.com> | 2019-08-01 17:44:12 +0200 |
---|---|---|
committer | Arne Döring <arne.doering@gmx.net> | 2019-08-01 17:44:12 +0200 |
commit | 829f7196708e1326513f8cceed0b63e67bbdb318 (patch) | |
tree | 1303780b837712b8aa341904bb82a2f8f2342649 | |
parent | 803406d07ce95189b08a16c7f51e2bf91f9c0c12 (diff) | |
download | Nim-829f7196708e1326513f8cceed0b63e67bbdb318.tar.gz |
Fix VM conversion to var type [bugfix] (#11866)
-rw-r--r-- | compiler/vm.nim | 4 | ||||
-rw-r--r-- | tests/vm/tconstobj.nim | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim index 34caec83f..27b067da2 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 3cf256eed..ac7148b59 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") |