* fixes #10838 * reject func in types instead * trigger tests
This commit is contained in:
parent
afeca3d9fe
commit
c19cd14fc9
2 changed files with 16 additions and 0 deletions
|
|
@ -1109,6 +1109,8 @@ proc parseProcExpr(p: var TParser; isExpr: bool; kind: TNodeKind): PNode =
|
||||||
result = newNodeI(nkProcTy, info)
|
result = newNodeI(nkProcTy, info)
|
||||||
if hasSignature:
|
if hasSignature:
|
||||||
addSon(result, params)
|
addSon(result, params)
|
||||||
|
if kind == nkFuncDef:
|
||||||
|
parMessage(p, "func keyword is not allowed in type descriptions, use proc with {.noSideEffect.} pragma instead")
|
||||||
addSon(result, pragmas)
|
addSon(result, pragmas)
|
||||||
|
|
||||||
proc isExprStart(p: TParser): bool =
|
proc isExprStart(p: TParser): bool =
|
||||||
|
|
|
||||||
14
tests/proc/tfunc_type.nim
Normal file
14
tests/proc/tfunc_type.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
discard """
|
||||||
|
errmsg: "func keyword is not allowed in type descriptions, use proc with {.noSideEffect.} pragma instead"
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
MyObject = object
|
||||||
|
fn: func(a: int): int
|
||||||
|
|
||||||
|
proc myproc(a: int): int =
|
||||||
|
echo "bla"
|
||||||
|
result = a
|
||||||
|
|
||||||
|
var x = MyObject(fn: myproc)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue