summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/sempass2.nim9
-rw-r--r--compiler/semstmts.nim44
2 files changed, 32 insertions, 21 deletions
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim
index 8193a3537..86e569d7a 100644
--- a/compiler/sempass2.nim
+++ b/compiler/sempass2.nim
@@ -514,8 +514,17 @@ proc propagateEffects(tracked: PEffects, n: PNode, s: PSym) =
     markSideEffect(tracked, s)
   mergeLockLevels(tracked, n, s.getLockLevel)
 
+proc procVarcheck(n: PNode) =
+  if n.kind in nkSymChoices:
+    for x in n: procVarCheck(x)
+  elif n.kind == nkSym and n.sym.magic != mNone:
+    localError(n.info, errXCannotBePassedToProcVar, n.sym.name.s)
+
 proc notNilCheck(tracked: PEffects, n: PNode, paramType: PType) =
   let n = n.skipConv
+  procVarcheck skipConvAndClosure(n)
+  #elif n.kind in nkSymChoices:
+  #  echo "came here"
   if paramType != nil and tfNotNil in paramType.flags and
       n.typ != nil and tfNotNil notin n.typ.flags:
     if n.kind == nkAddr:
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index fec0a80d3..c7f27f0a2 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -71,27 +71,29 @@ proc toCover(t: PType): BiggestInt =
   else:
     result = lengthOrd(skipTypes(t, abstractVar-{tyTypeDesc}))
 
-proc performProcvarCheck(c: PContext, info: TLineInfo, s: PSym) =
-  ## Checks that the given symbol is a proper procedure variable, meaning
-  ## that it
-  var smoduleId = getModule(s).id
-  if sfProcvar notin s.flags and s.typ.callConv == ccDefault and
-      smoduleId != c.module.id:
-    block outer:
-      for module in c.friendModules:
-        if smoduleId == module.id:
-          break outer
-      localError(info, errXCannotBePassedToProcVar, s.name.s)
-
-proc semProcvarCheck(c: PContext, n: PNode) =
-  var n = n.skipConv
-  if n.kind in nkSymChoices:
-    for x in n:
-      if x.sym.kind in {skProc, skMethod, skConverter, skIterator}:
-        performProcvarCheck(c, n.info, x.sym)
-  elif n.kind == nkSym and n.sym.kind in {skProc, skMethod, skConverter,
-                                        skIterator}:
-    performProcvarCheck(c, n.info, n.sym)
+when false:
+  proc performProcvarCheck(c: PContext, info: TLineInfo, s: PSym) =
+    ## Checks that the given symbol is a proper procedure variable, meaning
+    ## that it
+    var smoduleId = getModule(s).id
+    if sfProcvar notin s.flags and s.typ.callConv == ccDefault and
+        smoduleId != c.module.id:
+      block outer:
+        for module in c.friendModules:
+          if smoduleId == module.id:
+            break outer
+        localError(info, errXCannotBePassedToProcVar, s.name.s)
+
+template semProcvarCheck(c: PContext, n: PNode) =
+  when false:
+    var n = n.skipConv
+    if n.kind in nkSymChoices:
+      for x in n:
+        if x.sym.kind in {skProc, skMethod, skConverter, skIterator}:
+          performProcvarCheck(c, n.info, x.sym)
+    elif n.kind == nkSym and n.sym.kind in {skProc, skMethod, skConverter,
+                                          skIterator}:
+      performProcvarCheck(c, n.info, n.sym)
 
 proc semProc(c: PContext, n: PNode): PNode
 
1a7fdb09d ^
9c34d6ee0 ^

1a7fdb09d ^

83a9c3ba3 ^
60d437427 ^
9c34d6ee0 ^
1a7fdb09d ^

6b302bb71 ^
1a7fdb09d ^
a16e6bd22 ^
c3229dc1c ^
03b05bd34 ^

57dc4ca22 ^
5f400983d ^




57dc4ca22 ^
ae8eb1ec3 ^
03b05bd34 ^
a16e6bd22 ^
1a7fdb09d ^



93f74e4f9 ^
644318ad9 ^
a16e6bd22 ^
03b05bd34 ^
a16e6bd22 ^
5e32fc785 ^

03b05bd34 ^

9e170f115 ^
93f74e4f9 ^
d60fae576 ^




ae8eb1ec3 ^
823b3c250 ^
03b05bd34 ^
ae8eb1ec3 ^
a16e6bd22 ^
86c65db18 ^
f97decaa2 ^


93f74e4f9 ^
c3229dc1c ^
6b302bb71 ^
dbcffcfcc ^
bc9749310 ^
3c870d3bb ^

dbcffcfcc ^
506418ef5 ^
ae8eb1ec3 ^
506418ef5 ^
dbcffcfcc ^

506418ef5 ^
ae8eb1ec3 ^
03b05bd34 ^
a16e6bd22 ^
4f4501abb ^
fe7a2d60f ^
4f4501abb ^
9fc291831 ^
03b05bd34 ^
c3229dc1c ^
03b05bd34 ^

93f74e4f9 ^
a16e6bd22 ^
03b05bd34 ^
1a7fdb09d ^
93f74e4f9 ^
03b05bd34 ^
49d810f34 ^
03b05bd34 ^
ff25103c9 ^
ae0e5604f ^
49d810f34 ^
46ee026e7 ^
f97decaa2 ^

342834d7f ^


da4215af6 ^
0fff332b8 ^
342834d7f ^
46ee026e7 ^
c3229dc1c ^
c8da41721 ^
03b05bd34 ^
510392bc6 ^
46ee026e7 ^
da4215af6 ^
11a664dfb ^



46ee026e7 ^

b2d776197 ^
93f74e4f9 ^
46ee026e7 ^

03b05bd34 ^
46ee026e7 ^
03b05bd34 ^

ae8eb1ec3 ^
03b05bd34 ^
95614089a ^
03b05bd34 ^
ae8eb1ec3 ^
03b05bd34 ^




229a62384 ^
03b05bd34 ^
a55b90827 ^
03b05bd34 ^

da2fd42e6 ^
03b05bd34 ^

229a62384 ^
03b05bd34 ^




342834d7f ^
03b05bd34 ^



a16e6bd22 ^
342834d7f ^


6b38b37b4 ^
342834d7f ^


















6b38b37b4 ^
342834d7f ^
a16e6bd22 ^
03b05bd34 ^
ae8eb1ec3 ^
03b05bd34 ^


1a7fdb09d ^
03b05bd34 ^
9483b1126 ^
03b05bd34 ^




908b2cc2e ^
03b05bd34 ^
b67dea7a3 ^

9c34d6ee0 ^
03b05bd34 ^
83a9c3ba3 ^

60d437427 ^
03b05bd34 ^


dce0b3b00 ^
644318ad9 ^
03b05bd34 ^
528069a96 ^
03b05bd34 ^



03b05bd34 ^
03b05bd34 ^
d1cf04a38 ^
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233