From 15d2a92be024641c4e7a0f78dc2832206c63f0bb Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 16 Jul 2019 15:43:25 +0200 Subject: [PATCH] fixes #11747 --- compiler/semexprs.nim | 3 +++ tests/metatype/ttypedesc3.nim | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 0c20d2c207..bdf742bf15 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1414,6 +1414,9 @@ proc semDeref(c: PContext, n: PNode): PNode = var t = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar, tyLent, tyAlias, tySink, tyOwned}) case t.kind of tyRef, tyPtr: n.typ = t.lastSon + of tyTypeDesc: + # typeof(x[]) is still a typedesc: + n.typ = makeTypeDesc(c, t.lastSon.lastSon) else: result = nil #GlobalError(n.sons[0].info, errCircumNeedsPointer) diff --git a/tests/metatype/ttypedesc3.nim b/tests/metatype/ttypedesc3.nim index bd973eed14..a906905919 100644 --- a/tests/metatype/ttypedesc3.nim +++ b/tests/metatype/ttypedesc3.nim @@ -5,6 +5,7 @@ proc Child method Base yield Base yield Child +12 ''' """ @@ -27,3 +28,16 @@ when false: for s in Base.it: echo s for s in Child.it: echo s #<- bug #2662 + + +# bug #11747 + +type + MyType = object + a: int32 + b: int32 + c: int32 + + MyRefType = ref MyType + +echo sizeof(MyRefType[])