From bfca977d5fc2f38c04edef2647ef01c80a810c23 Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 2 Jul 2013 19:44:40 +0200 Subject: [PATCH] fixes #505 --- compiler/semexprs.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index ff68d6b8e0..57457c1013 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -750,8 +750,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] = semExpr(c, buildStringify(c, arg)) - + n.sons[i] = semExprWithType(c, buildStringify(c, arg)) + let t = n.sons[i].typ + if t == nil or t.skipTypes(abstractInst).kind != tyString: + LocalError(n.info, errGenerated, + "implicitly invoked '$' does not return string") let t = n.sons[0].typ if tfNoSideEffect notin t.flags: incl(c.p.owner.flags, sfSideEffect) result = n