summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-12-22 18:37:14 +0100
committerAraq <rumpf_a@web.de>2018-12-22 18:39:20 +0100
commitbdb67201b2713a4045167fd8feb407df98a43997 (patch)
tree3745f822e1eda2e93c43f8810bef451d53383611
parent253936385143cb9d58f565dee0f1b5768accc81e (diff)
downloadNim-bdb67201b2713a4045167fd8feb407df98a43997.tar.gz
fixes #10033 [backport]
-rw-r--r--compiler/ccgtypes.nim4
-rw-r--r--tests/objvariant/tyaoption.nim25
2 files changed, 26 insertions, 3 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 235bd16d8..243aa87de 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -970,9 +970,9 @@ proc genTypeInfoAux(m: BModule, typ, origType: PType, name: Rope;
 
 proc discriminatorTableName(m: BModule, objtype: PType, d: PSym): Rope =
   # bugfix: we need to search the type that contains the discriminator:
-  var objtype = objtype
+  var objtype = objtype.skipTypes(abstractPtrs)
   while lookupInRecord(objtype.n, d.name) == nil:
-    objtype = objtype.sons[0]
+    objtype = objtype.sons[0].skipTypes(abstractPtrs)
   if objtype.sym == nil:
     internalError(m.config, d.info, "anonymous obj with discriminator")
   result = "NimDT_$1_$2" % [rope($hashType(objtype)), rope(d.name.s.mangle)]
diff --git a/tests/objvariant/tyaoption.nim b/tests/objvariant/tyaoption.nim
index 7a29b8008..80bfa4bae 100644
--- a/tests/objvariant/tyaoption.nim
+++ b/tests/objvariant/tyaoption.nim
@@ -1,7 +1,8 @@
 discard """
   output: '''some(str), some(5), none
 some(5!)
-some(10)'''
+some(10)
+34'''
 """
 
 import strutils
@@ -45,3 +46,25 @@ let a3 = intOrString(some(5))
 #echo a1
 echo a2
 echo a3
+
+
+# bug #10033
+
+type
+  Token = enum
+    Int,
+    Float
+
+  Base = ref object of RootObj
+    case token: Token
+    of Int:
+      bInt: int
+    of Float:
+      bFloat: float
+
+  Child = ref object of Base
+
+let c = new Child
+c.token = Int
+c.bInt = 34
+echo c.bInt