summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/ccgexprs.nim10
-rwxr-xr-xcompiler/semexprs.nim2
2 files changed, 9 insertions, 3 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index d02c20559..3f3a60b7a 100755
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -765,11 +765,15 @@ proc genIfExpr(p: BProc, n: PNode, d: var TLoc) =
     genAssignment(p, d, tmp, {}) # no need for deep copying
 
 proc genEcho(p: BProc, n: PNode) =
+  # this unusal way of implementing it ensures that e.g. ``echo("hallo", 45)``
+  # is threadsafe.
+  var args: PRope = nil
   var a: TLoc
-  for i in countup(1, sonsLen(n) - 1):
+  for i in countup(1, n.len-1):
     initLocExpr(p, n.sons[i], a)
-    appcg(p, cpsStmts, "#rawEcho($1);$n", [rdLoc(a)])
-  appcg(p, cpsStmts, "#rawEchoNL();$n")
+    appf(args, ", ($1)->data", [rdLoc(a)])
+  appcg(p, cpsStmts, "printf(\"" & repeatStr(n.len-1, "%s") &
+        "\\n\"$1);$n", [args])
 
 proc genCall(p: BProc, t: PNode, d: var TLoc) =
   var op, a: TLoc
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index a7b35f08b..38db93988 100755
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -527,6 +527,8 @@ proc LookUpForDefined(c: PContext, n: PNode, onlyCurrentScope: bool): PSym =
         GlobalError(n.sons[1].info, errIdentifierExpected, "")
   of nkAccQuoted:
     result = lookupForDefined(c, considerAcc(n), onlyCurrentScope)
+  of nkSym:
+    result = n.sym
   else: 
     GlobalError(n.info, errIdentifierExpected, renderTree(n))
     result = nil