diff options
-rw-r--r-- | lib/system.nim | 2 | ||||
-rw-r--r-- | tests/system/tostring.nim | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/system.nim b/lib/system.nim index 92f51fe7e..bfd8a31e5 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3972,7 +3972,7 @@ proc addQuoted*[T](s: var string, x: T) = ## tmp.add(", ") ## tmp.addQuoted('c') ## assert(tmp == """1, "string", 'c'""") - when T is string: + when T is string or T is cstring: s.add("\"") for c in x: # Only ASCII chars are escaped to avoid butchering diff --git a/tests/system/tostring.nim b/tests/system/tostring.nim index 42c07c0a4..04b37f133 100644 --- a/tests/system/tostring.nim +++ b/tests/system/tostring.nim @@ -106,4 +106,12 @@ var nilstring: string bar(nilstring) static: - stringCompare() \ No newline at end of file + stringCompare() + +# bug 8847 +var a2: cstring = "fo\"o2" + +block: + var s: string + s.addQuoted a2 + doAssert s == "\"fo\\\"o2\"" |