summary refs log tree commit diff stats
path: root/lib/pure/strformat.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pure/strformat.nim')
-rw-r--r--lib/pure/strformat.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/pure/strformat.nim b/lib/pure/strformat.nim
index f13eb5e8e..8623a43e0 100644
--- a/lib/pure/strformat.nim
+++ b/lib/pure/strformat.nim
@@ -285,7 +285,11 @@ macro `&`*(pattern: string): untyped =
   var i = 0
   let res = genSym(nskVar, "fmtRes")
   result = newNimNode(nnkStmtListExpr, lineInfoFrom=pattern)
-  result.add newVarStmt(res, newCall(bindSym"newStringOfCap", newLit(f.len + count(f, '{')*10)))
+  # XXX: https://github.com/nim-lang/Nim/issues/8405
+  # When compiling with -d:useNimRtl, certain procs such as `count` from the strutils
+  # module are not accessible at compile-time:
+  let expectedGrowth = when defined(useNimRtl): 0 else: count(f, '{') * 10
+  result.add newVarStmt(res, newCall(bindSym"newStringOfCap", newLit(f.len + expectedGrowth)))
   var strlit = ""
   while i < f.len:
     if f[i] == '{':