remove the need for the .procvar annotation

This commit is contained in:
Andreas Rumpf 2017-04-03 16:35:41 +02:00
commit 08f5087d2c
4 changed files with 37 additions and 30 deletions

View file

@ -514,8 +514,17 @@ proc propagateEffects(tracked: PEffects, n: PNode, s: PSym) =
markSideEffect(tracked, s) markSideEffect(tracked, s)
mergeLockLevels(tracked, n, s.getLockLevel) 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) = proc notNilCheck(tracked: PEffects, n: PNode, paramType: PType) =
let n = n.skipConv let n = n.skipConv
procVarcheck skipConvAndClosure(n)
#elif n.kind in nkSymChoices:
# echo "came here"
if paramType != nil and tfNotNil in paramType.flags and if paramType != nil and tfNotNil in paramType.flags and
n.typ != nil and tfNotNil notin n.typ.flags: n.typ != nil and tfNotNil notin n.typ.flags:
if n.kind == nkAddr: if n.kind == nkAddr:

View file

@ -71,6 +71,7 @@ proc toCover(t: PType): BiggestInt =
else: else:
result = lengthOrd(skipTypes(t, abstractVar-{tyTypeDesc})) result = lengthOrd(skipTypes(t, abstractVar-{tyTypeDesc}))
when false:
proc performProcvarCheck(c: PContext, info: TLineInfo, s: PSym) = proc performProcvarCheck(c: PContext, info: TLineInfo, s: PSym) =
## Checks that the given symbol is a proper procedure variable, meaning ## Checks that the given symbol is a proper procedure variable, meaning
## that it ## that it
@ -83,7 +84,8 @@ proc performProcvarCheck(c: PContext, info: TLineInfo, s: PSym) =
break outer break outer
localError(info, errXCannotBePassedToProcVar, s.name.s) localError(info, errXCannotBePassedToProcVar, s.name.s)
proc semProcvarCheck(c: PContext, n: PNode) = template semProcvarCheck(c: PContext, n: PNode) =
when false:
var n = n.skipConv var n = n.skipConv
if n.kind in nkSymChoices: if n.kind in nkSymChoices:
for x in n: for x in n:

View file

@ -1003,16 +1003,6 @@ Nim supports these `calling conventions`:idx:\:
Most calling conventions exist only for the Windows 32-bit platform. Most calling conventions exist only for the Windows 32-bit platform.
Assigning/passing a procedure to a procedural variable is only allowed if one
of the following conditions hold:
1) The procedure that is accessed resides in the current module.
2) The procedure is marked with the ``procvar`` pragma (see `procvar pragma <#pragmas-procvar-pragma>`_).
3) The procedure has a calling convention that differs from ``nimcall``.
4) The procedure is anonymous.
The rules' purpose is to prevent the case that extending a non-``procvar``
procedure with default parameters breaks client code.
The default calling convention is ``nimcall``, unless it is an inner proc (a The default calling convention is ``nimcall``, unless it is an inner proc (a
proc inside of a proc). For an inner proc an analysis is performed whether it proc inside of a proc). For an inner proc an analysis is performed whether it
accesses its environment. If it does so, it has the calling convention accesses its environment. If it does so, it has the calling convention

View file

@ -112,6 +112,12 @@ found `here <http://nim-lang.org/docs/manual.html#pragmas-used-pragma>`_.
This is particularly useful for DSLs that help in tree construction. This is particularly useful for DSLs that help in tree construction.
Language changes
----------------
- The ``.procvar`` annotation is not required anymore. That doesn't mean you
can pass ``system.$`` to ``map`` just yet though.
Bugfixes Bugfixes
-------- --------