diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 33ab827d3..d403aeef1 100755 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -36,16 +36,6 @@ proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}): PNode = GlobalError(n.info, errExprXHasNoType, renderTree(result, {renderNoComments})) -proc semExprWithTypeNoDeref(c: PContext, n: PNode, - flags: TExprFlags = {}): PNode = - result = semExpr(c, n, flags) - if result.kind == nkEmpty: - # do not produce another redundant error message: - raiseRecoverableError() - if result.typ == nil: - GlobalError(n.info, errExprXHasNoType, - renderTree(result, {renderNoComments})) - proc semSymGenericInstantiation(c: PContext, n: PNode, s: PSym): PNode = result = symChoice(c, n, s) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 400844902..9a6af9ecd 100755 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -581,8 +581,12 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode, addSon(result.n, newSymNode(arg)) addSon(result, typ) if n.sons[0].kind != nkEmpty: - result.sons[0] = paramType(c, n.sons[0], genericParams, cl) - res.typ = result.sons[0] + var r = paramType(c, n.sons[0], genericParams, cl) + # turn explicit 'void' return type into 'nil' because the rest of the + # compiler only checks for 'nil': + if skipTypes(r, {tyGenericInst}).kind != tyEmpty: + result.sons[0] = r + res.typ = result.sons[0] proc semStmtListType(c: PContext, n: PNode, prev: PType): PType = checkMinSonsLen(n, 1) diff --git a/tests/accept/compile/tvoid.nim b/tests/accept/compile/tvoid.nim new file mode 100644 index 000000000..5ef076293 --- /dev/null +++ b/tests/accept/compile/tvoid.nim @@ -0,0 +1,13 @@ +discard """ + output: "he, no return type; a string" +""" + +proc ReturnT[T](): T = + when T is void: + echo "he, no return type;" + else: + result = " a string" + +ReturnT[void]() +echo ReturnT[string]() + diff --git a/todo.txt b/todo.txt index 23ecc52c5..828add659 100755 --- a/todo.txt +++ b/todo.txt @@ -6,7 +6,12 @@ Version 0.8.14 * add ``modGet`` for generics * documentation * provide ``mod`` as an alternative syntax for ``var`` -- document Nimrod's two phase symbol lookup for generics +- document: + * Nimrod's two phase symbol lookup in generics + * type constraints for generics + * void type + * ``is`` operator for type equivalence + - optional indentation for 'case' statement - make threadvar efficient again on linux after testing - test the sort implementation again diff --git a/web/news.txt b/web/news.txt index d919fc6cd..b6776bbb2 100755 --- a/web/news.txt +++ b/web/news.txt @@ -39,6 +39,8 @@ Language Additions ------------------ - Added new ``is`` and ``of`` operators. +- The built-in type ``void`` can be used to denote the absense of any type. + This is only needed in generic contexts. Compiler Additions