From ac271e76b18110bea8046af64ceccd6b804978dd Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 16 Mar 2014 11:39:53 +0200 Subject: more robust handling of proc signatures containing inter-param type references --- compiler/semexprs.nim | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'compiler/semexprs.nim') diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 133b4ac1e..5a12156ec 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -899,10 +899,13 @@ proc makeDeref(n: PNode): PNode = addSon(result, a) t = skipTypes(t.sons[0], {tyGenericInst}) -proc readTypeParameter(c: PContext, ty: PType, +const tyTypeParamsHolders = {tyGenericInst, tyCompositeTypeClass} + +proc readTypeParameter(c: PContext, typ: PType, paramName: PIdent, info: TLineInfo): PNode = - internalAssert ty.kind == tyGenericInst - let ty = ty.skipGenericAlias + let ty = if typ.kind == tyGenericInst: typ.skipGenericAlias + else: (internalAssert typ.kind == tyCompositeTypeClass; typ.sons[1]) + let tbody = ty.sons[0] for s in countup(0, tbody.len-2): let tParam = tbody.sons[s] @@ -946,7 +949,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode = result.typ = ty markUsed(n, f) return - of tyGenericInst: + of tyTypeParamsHolders: return readTypeParameter(c, ty, i, n.info) of tyObject, tyTuple: if ty.n.kind == nkRecList: @@ -996,7 +999,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode = result = n # we didn't find any field, let's look for a generic param - if result == nil and n.sons[0].typ.kind == tyGenericInst: + if result == nil and n.sons[0].typ.kind in tyTypeParamsHolders: result = readTypeParameter(c, n.sons[0].typ, i, n.info) proc dotTransformation(c: PContext, n: PNode): PNode = -- cgit 1.4.1-2-gfad0 ut type='hidden' name='id' value='f71eaf66be35b2f4e7c12ebbb16ec301564bb0ab'/>
path: root/compiler/trees.nim
blob: 2c631af99543910e49b8075914f98d3f8a480f83 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170