This commit is contained in:
Araq
2016-12-30 02:21:15 +01:00
parent 45001632ce
commit cfea779e23
2 changed files with 17 additions and 5 deletions

View File

@@ -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

View File

@@ -0,0 +1,8 @@
discard """
errormsg: "'+' cannot be passed to a procvar"
line: 8
"""
# bug #2050
let v: proc (a, b: int): int = `+`