Skip to content

Commit 15d2a92

Browse files
committed
fixes #11747
1 parent 102b71f commit 15d2a92

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

compiler/semexprs.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,9 @@ proc semDeref(c: PContext, n: PNode): PNode =
14141414
var t = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar, tyLent, tyAlias, tySink, tyOwned})
14151415
case t.kind
14161416
of tyRef, tyPtr: n.typ = t.lastSon
1417+
of tyTypeDesc:
1418+
# typeof(x[]) is still a typedesc:
1419+
n.typ = makeTypeDesc(c, t.lastSon.lastSon)
14171420
else: result = nil
14181421
#GlobalError(n.sons[0].info, errCircumNeedsPointer)
14191422

tests/metatype/ttypedesc3.nim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ proc Child
55
method Base
66
yield Base
77
yield Child
8+
12
89
'''
910
"""
1011

@@ -27,3 +28,16 @@ when false:
2728

2829
for s in Base.it: echo s
2930
for s in Child.it: echo s #<- bug #2662
31+
32+
33+
# bug #11747
34+
35+
type
36+
MyType = object
37+
a: int32
38+
b: int32
39+
c: int32
40+
41+
MyRefType = ref MyType
42+
43+
echo sizeof(MyRefType[])

0 commit comments

Comments
 (0)