parent
88814bbe98
commit
ae9bb4474b
2 changed files with 15 additions and 2 deletions
|
|
@ -1904,6 +1904,10 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
||||||
discard
|
discard
|
||||||
popProcCon(c)
|
popProcCon(c)
|
||||||
else:
|
else:
|
||||||
|
if s.kind in {skProc, skFunc} and s.typ[0] != nil and s.typ[0].kind == tyUntyped:
|
||||||
|
# `auto` is represented as `tyUntyped` at this point in compilation.
|
||||||
|
localError(c.config, n[paramsPos][0].info, "return type 'auto' cannot be used in forward declarations")
|
||||||
|
|
||||||
if s.kind == skMethod: semMethodPrototype(c, s, n)
|
if s.kind == skMethod: semMethodPrototype(c, s, n)
|
||||||
if proto != nil: localError(c.config, n.info, errImplOfXexpected % proto.name.s)
|
if proto != nil: localError(c.config, n.info, errImplOfXexpected % proto.name.s)
|
||||||
if {sfImportc, sfBorrow, sfError} * s.flags == {} and s.magic == mNone:
|
if {sfImportc, sfBorrow, sfError} * s.flags == {} and s.magic == mNone:
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim check $file"
|
cmd: "nim check $file"
|
||||||
errmsg: ""
|
errmsg: ""
|
||||||
nimout: '''tillegalreturntype.nim(8, 11) Error: return type 'typed' is only valid for macros and templates
|
nimout: '''
|
||||||
tillegalreturntype.nim(11, 11) Error: return type 'untyped' is only valid for macros and templates'''
|
tillegalreturntype.nim(11, 11) Error: return type 'typed' is only valid for macros and templates
|
||||||
|
tillegalreturntype.nim(14, 11) Error: return type 'untyped' is only valid for macros and templates
|
||||||
|
tillegalreturntype.nim(17, 41) Error: return type 'auto' cannot be used in forward declarations
|
||||||
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc x(): typed =
|
proc x(): typed =
|
||||||
|
|
@ -10,3 +13,9 @@ proc x(): typed =
|
||||||
|
|
||||||
proc y(): untyped =
|
proc y(): untyped =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
proc test_proc[T, U](arg1: T, arg2: U): auto
|
||||||
|
|
||||||
|
proc test_proc[T, U](arg1: T, arg2: U): auto =
|
||||||
|
echo "Proc has been called"
|
||||||
|
return arg1 / arg2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue