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