fixes 'echo nil' codegen bug

This commit is contained in:
Araq 2015-05-02 23:53:48 +02:00
commit 6cb3635ca0
2 changed files with 6 additions and 3 deletions

View file

@ -964,8 +964,11 @@ proc genEcho(p: BProc, n: PNode) =
var args: Rope = nil var args: Rope = nil
var a: TLoc var a: TLoc
for i in countup(0, n.len-1): for i in countup(0, n.len-1):
initLocExpr(p, n.sons[i], a) if n.sons[i].skipConv.kind == nkNilLit:
addf(args, ", $1? ($1)->data:\"nil\"", [rdLoc(a)]) add(args, ", \"nil\"")
else:
initLocExpr(p, n.sons[i], a)
addf(args, ", $1? ($1)->data:\"nil\"", [rdLoc(a)])
linefmt(p, cpsStmts, "printf($1$2);$n", linefmt(p, cpsStmts, "printf($1$2);$n",
makeCString(repeat("%s", n.len) & tnl), args) makeCString(repeat("%s", n.len) & tnl), args)

View file

@ -1,7 +1,7 @@
# #
# #
# The Nim Compiler # The Nim Compiler
# (c) Copyright 2013 Andreas Rumpf # (c) Copyright 2015 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.