mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
'auto' can be inferred to be 'void'
This commit is contained in:
@@ -1337,7 +1337,12 @@ proc semProcBody(c: PContext, n: PNode): PNode =
|
||||
|
||||
if c.p.owner.kind notin {skMacro, skTemplate} and
|
||||
c.p.resultSym != nil and c.p.resultSym.typ.isMetaType:
|
||||
localError(c.p.resultSym.info, errCannotInferReturnType)
|
||||
if isEmptyType(result.typ):
|
||||
# we inferred a 'void' return type:
|
||||
c.p.resultSym.typ = nil
|
||||
c.p.owner.typ.sons[0] = nil
|
||||
else:
|
||||
localError(c.p.resultSym.info, errCannotInferReturnType)
|
||||
|
||||
closeScope(c)
|
||||
|
||||
|
||||
9
tests/types/tauto_canbe_void.nim
Normal file
9
tests/types/tauto_canbe_void.nim
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
import future
|
||||
|
||||
template tempo(s: expr) =
|
||||
s("arg")
|
||||
|
||||
tempo((s: string)->auto => echo(s))
|
||||
tempo((s: string) => echo(s))
|
||||
|
||||
Reference in New Issue
Block a user