diff options
-rw-r--r-- | compiler/parser.nim | 2 | ||||
-rw-r--r-- | tests/proc/tfunc_type.nim | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index 260e57cdb..855fc2f4a 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -1109,6 +1109,8 @@ proc parseProcExpr(p: var TParser; isExpr: bool; kind: TNodeKind): PNode = result = newNodeI(nkProcTy, info) if hasSignature: 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) proc isExprStart(p: TParser): bool = diff --git a/tests/proc/tfunc_type.nim b/tests/proc/tfunc_type.nim new file mode 100644 index 000000000..2a583fcb9 --- /dev/null +++ b/tests/proc/tfunc_type.nim @@ -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) \ No newline at end of file |