produce errors on proc types with implicit empty param lists.

This commit is contained in:
Zahary Karadjov 2012-04-20 22:32:36 +03:00
commit 2f4ae65917
3 changed files with 13 additions and 11 deletions

View file

@ -626,9 +626,9 @@ proc parseParamList(p: var TParser, retColon = true): PNode =
optInd(p, a) optInd(p, a)
optPar(p) optPar(p)
eat(p, tkParRi) eat(p, tkParRi)
let b = if retColon: p.tok.tokType == tkColon let hasRet = if retColon: p.tok.tokType == tkColon
else: p.tok.tokType == tkOpr and IdentEq(p.tok.ident, "->") else: p.tok.tokType == tkOpr and IdentEq(p.tok.ident, "->")
if b: if hasRet:
getTok(p) getTok(p)
optInd(p, result) optInd(p, result)
result.sons[0] = parseTypeDesc(p) result.sons[0] = parseTypeDesc(p)
@ -662,6 +662,7 @@ proc parseProcExpr(p: var TParser, isExpr: bool): PNode =
info: TLineInfo info: TLineInfo
info = parLineInfo(p) info = parLineInfo(p)
getTok(p) getTok(p)
let hasSignature = p.tok.tokType in {tkParLe, tkColon}
params = parseParamList(p) params = parseParamList(p)
pragmas = optPragmas(p) pragmas = optPragmas(p)
if (p.tok.tokType == tkEquals) and isExpr: if (p.tok.tokType == tkEquals) and isExpr:
@ -675,8 +676,9 @@ proc parseProcExpr(p: var TParser, isExpr: bool): PNode =
addSon(result, parseStmt(p)) addSon(result, parseStmt(p))
else: else:
result = newNodeI(nkProcTy, info) result = newNodeI(nkProcTy, info)
addSon(result, params) if hasSignature:
addSon(result, pragmas) addSon(result, params)
addSon(result, pragmas)
proc isExprStart(p: TParser): bool = proc isExprStart(p: TParser): bool =
case p.tok.tokType case p.tok.tokType

View file

@ -1889,7 +1889,7 @@ proc setpwent*() {.importc, header: "<pwd.h>".}
proc uname*(a1: var Tutsname): cint {.importc, header: "<sys/utsname.h>".} proc uname*(a1: var Tutsname): cint {.importc, header: "<sys/utsname.h>".}
proc pthread_atfork*(a1, a2, a3: proc {.noconv.}): cint {. proc pthread_atfork*(a1, a2, a3: proc () {.noconv.}): cint {.
importc, header: "<pthread.h>".} importc, header: "<pthread.h>".}
proc pthread_attr_destroy*(a1: ptr Tpthread_attr): cint {. proc pthread_attr_destroy*(a1: ptr Tpthread_attr): cint {.
importc, header: "<pthread.h>".} importc, header: "<pthread.h>".}
@ -2015,7 +2015,7 @@ proc pthread_mutexattr_setprotocol*(a1: ptr Tpthread_mutexattr, a2: cint): cint
proc pthread_mutexattr_setpshared*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} proc pthread_mutexattr_setpshared*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
proc pthread_mutexattr_settype*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} proc pthread_mutexattr_settype*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".}
proc pthread_once*(a1: ptr Tpthread_once, a2: proc {.noconv.}): cint {.importc, header: "<pthread.h>".} proc pthread_once*(a1: ptr Tpthread_once, a2: proc () {.noconv.}): cint {.importc, header: "<pthread.h>".}
proc pthread_rwlock_destroy*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".} proc pthread_rwlock_destroy*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".}
proc pthread_rwlock_init*(a1: ptr Tpthread_rwlock, proc pthread_rwlock_init*(a1: ptr Tpthread_rwlock,

View file

@ -971,7 +971,7 @@ proc toBiggestInt*(f: biggestfloat): biggestint {.
## rounds `f` if it does not contain an integer value. If the conversion ## rounds `f` if it does not contain an integer value. If the conversion
## fails (because `f` is infinite for example), `EInvalidValue` is raised. ## fails (because `f` is infinite for example), `EInvalidValue` is raised.
proc addQuitProc*(QuitProc: proc {.noconv.}) {.importc: "atexit", nodecl.} proc addQuitProc*(QuitProc: proc() {.noconv.}) {.importc: "atexit", nodecl.}
## adds/registers a quit procedure. Each call to ``addQuitProc`` ## adds/registers a quit procedure. Each call to ``addQuitProc``
## registers another quit procedure. Up to 30 procedures can be ## registers another quit procedure. Up to 30 procedures can be
## registered. They are executed on a last-in, first-out basis ## registered. They are executed on a last-in, first-out basis
@ -1511,7 +1511,7 @@ const nimrodStackTrace = compileOption("stacktrace")
# of the code # of the code
var var
dbgLineHook*: proc dbgLineHook*: proc ()
## set this variable to provide a procedure that should be called before ## set this variable to provide a procedure that should be called before
## each executed instruction. This should only be used by debuggers! ## each executed instruction. This should only be used by debuggers!
## Only code compiled with the ``debugger:on`` switch calls this hook. ## Only code compiled with the ``debugger:on`` switch calls this hook.
@ -1531,7 +1531,7 @@ var
## do when setting this. If ``localRaiseHook`` returns false, the exception ## do when setting this. If ``localRaiseHook`` returns false, the exception
## is caught and does not propagate further through the call stack. ## is caught and does not propagate further through the call stack.
outOfMemHook*: proc outOfMemHook*: proc ()
## set this variable to provide a procedure that should be called ## set this variable to provide a procedure that should be called
## in case of an `out of memory`:idx: event. The standard handler ## in case of an `out of memory`:idx: event. The standard handler
## writes an error message and terminates the program. `outOfMemHook` can ## writes an error message and terminates the program. `outOfMemHook` can