summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semstmts.nim14
-rw-r--r--tests/errmsgs/tcannot_capture_builtin.nim8
2 files changed, 17 insertions, 5 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index ec4279e60..365109249 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -70,7 +70,7 @@ proc toCover(t: PType): BiggestInt =
   else:
     result = lengthOrd(skipTypes(t, abstractVar-{tyTypeDesc}))
 
-proc performProcvarCheck(c: PContext, n: PNode, s: PSym) =
+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
@@ -80,13 +80,17 @@ proc performProcvarCheck(c: PContext, n: PNode, s: PSym) =
       for module in c.friendModules:
         if smoduleId == module.id:
           break outer
-      localError(n.info, errXCannotBePassedToProcVar, s.name.s)
+      localError(info, errXCannotBePassedToProcVar, s.name.s)
 
 proc semProcvarCheck(c: PContext, n: PNode) =
-  let n = n.skipConv
-  if n.kind == nkSym and n.sym.kind in {skProc, skMethod, skConverter,
+  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, n.sym)
+    performProcvarCheck(c, n.info, n.sym)
 
 proc semProc(c: PContext, n: PNode): PNode
 
diff --git a/tests/errmsgs/tcannot_capture_builtin.nim b/tests/errmsgs/tcannot_capture_builtin.nim
new file mode 100644
index 000000000..3b8aae241
--- /dev/null
+++ b/tests/errmsgs/tcannot_capture_builtin.nim
@@ -0,0 +1,8 @@
+discard """
+errormsg: "'+' cannot be passed to a procvar"
+line: 8
+"""
+
+# bug #2050
+
+let v: proc (a, b: int): int = `+`