summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-07-03 00:14:54 +0200
committerAraq <rumpf_a@web.de>2015-07-03 00:20:34 +0200
commitcdc6529ccfbbabebf9e0da98334e1c4ee6e3973b (patch)
tree7ae570ac120aeaca8b7a05a21cf663b54075c373
parent3df9d2bd0ce3e7af872cb99cae96d8108510b64c (diff)
downloadNim-cdc6529ccfbbabebf9e0da98334e1c4ee6e3973b.tar.gz
fixes #3038
-rw-r--r--compiler/semtypes.nim4
-rw-r--r--tests/objects/trefobjsyntax3.nim28
2 files changed, 30 insertions, 2 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index ff68373c4..d0cd70947 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -629,7 +629,7 @@ proc skipGenericInvocation(t: PType): PType {.inline.} =
   result = t
   if result.kind == tyGenericInvocation:
     result = result.sons[0]
-  while result.kind in {tyGenericInst, tyGenericBody}:
+  while result.kind in {tyGenericInst, tyGenericBody, tyRef, tyPtr}:
     result = lastSon(result)
 
 proc addInheritedFields(c: PContext, check: var IntSet, pos: var int,
@@ -651,7 +651,7 @@ proc semObjectNode(c: PContext, n: PNode, prev: PType): PType =
     if base.isNil:
       localError(n.info, errIllegalRecursionInTypeX, "object")
     else:
-      var concreteBase = skipGenericInvocation(base).skipTypes(skipPtrs)
+      var concreteBase = skipGenericInvocation(base)
       if concreteBase.kind == tyObject and tfFinal notin concreteBase.flags:
         addInheritedFields(c, check, pos, concreteBase)
       else:
diff --git a/tests/objects/trefobjsyntax3.nim b/tests/objects/trefobjsyntax3.nim
new file mode 100644
index 000000000..2d466eeda
--- /dev/null
+++ b/tests/objects/trefobjsyntax3.nim
@@ -0,0 +1,28 @@
+# bug #2540
+
+type
+  BaseSceneNode[T] = ref object of RootObj
+    children*: seq[BaseSceneNode[T]]
+    parent*: BaseSceneNode[T]
+
+  SceneNode[T] = ref object of BaseSceneNode[T]
+
+  SomeObj = ref object
+
+proc newSceneNode[T](): SceneNode[T] =
+  new result
+  result.children = @[]
+
+var aNode = newSceneNode[SomeObj]()
+
+
+# bug #3038
+
+type
+  Data[T] = ref object of RootObj
+    data: T
+  Type = ref object of RootObj
+  SubType[T] = ref object of Type
+    data: Data[T]
+  SubSubType = ref object of SubType
+  SubSubSubType = ref object of SubSubType