diff options
author | Araq <rumpf_a@web.de> | 2013-09-10 23:49:53 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-09-10 23:49:53 +0200 |
commit | 4d86b8a83c1d3e485811afd42ff5a7cd02c9daa8 (patch) | |
tree | 4866f42bf8c7d37cd5fb201ffdd188f48c3ea257 /compiler | |
parent | 275c7ccf82e03622258c135890c0419e70ee0884 (diff) | |
download | Nim-4d86b8a83c1d3e485811afd42ff5a7cd02c9daa8.tar.gz |
fixes #588
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semcall.nim | 13 | ||||
-rw-r--r-- | compiler/semexprs.nim | 13 |
2 files changed, 14 insertions, 12 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim index c8f150922..9e9614796 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -34,13 +34,12 @@ proc sameMethodDispatcher(a, b: PSym): bool = proc determineType(c: PContext, s: PSym) -proc - pickBestCandidate(c: PContext, headSymbol: PNode, - n, orig: PNode, - initialBinding: PNode, - filter: TSymKinds, - best, alt: var TCandidate, - errors: var seq[string]) = +proc pickBestCandidate(c: PContext, headSymbol: PNode, + n, orig: PNode, + initialBinding: PNode, + filter: TSymKinds, + best, alt: var TCandidate, + errors: var seq[string]) = var o: TOverloadIter var sym = initOverloadIter(o, c, headSymbol) var symScope = o.lastOverloadScope diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 5dce7be54..dfd054e42 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -36,7 +36,7 @@ proc semOperand(c: PContext, n: PNode, flags: TExprFlags = {}): PNode = proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}): PNode = result = semExpr(c, n, flags) - if result.kind == nkEmpty: + if result.isNil or result.kind == nkEmpty: # do not produce another redundant error message: #raiseRecoverableError("") result = errorNode(c, n) @@ -786,9 +786,11 @@ proc semEcho(c: PContext, n: PNode): PNode = checkMinSonsLen(n, 1) for i in countup(1, sonsLen(n) - 1): var arg = semExprWithType(c, n.sons[i]) - n.sons[i] = semExprWithType(c, buildStringify(c, arg)) - let t = n.sons[i].typ - if t == nil or t.skipTypes(abstractInst).kind != tyString: + arg = semExprWithType(c, buildStringify(c, arg)) + n.sons[i] = arg + let t = arg.typ + if (t == nil or t.skipTypes(abstractInst).kind != tyString) and + arg.kind != nkEmpty: LocalError(n.info, errGenerated, "implicitly invoked '$' does not return string") let t = n.sons[0].typ @@ -807,7 +809,8 @@ proc buildEchoStmt(c: PContext, n: PNode): PNode = var arg = buildStringify(c, n) # problem is: implicit '$' is not checked for semantics yet. So we give up # and check 'arg' for semantics again: - addSon(result, semExpr(c, arg)) + arg = semExpr(c, arg) + if arg != nil: addSon(result, arg) proc semExprNoType(c: PContext, n: PNode): PNode = result = semExpr(c, n, {efWantStmt}) |