summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/system/repr_v2.nim14
-rw-r--r--tests/arc/trepr.nim4
-rw-r--r--tests/destructor/tfinalizer.nim2
3 files changed, 11 insertions, 9 deletions
diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim
index 407a06844..be1a4cf3a 100644
--- a/lib/system/repr_v2.nim
+++ b/lib/system/repr_v2.nim
@@ -27,21 +27,23 @@ proc repr*(x: bool): string {.magic: "BoolToStr", noSideEffect.}
   ## repr for a boolean argument. Returns `x`
   ## converted to the string "false" or "true".
 
-proc repr*(x: char): string {.magic: "CharToStr", noSideEffect.}
+proc repr*(x: char): string {.noSideEffect.} =
   ## repr for a character argument. Returns `x`
   ## converted to a string.
   ##
   ## .. code-block:: Nim
   ##   assert repr('c') == "c"
+  '\'' & $x & '\''
 
-proc repr*(x: cstring): string {.magic: "CStrToStr", noSideEffect.}
+proc repr*(x: cstring): string {.noSideEffect.} =
   ## repr for a CString argument. Returns `x`
-  ## converted to a string.
+  ## converted to a quoted string.
+  '"' & $x & '"'
 
-proc repr*(x: string): string {.magic: "StrToStr", noSideEffect.}
+proc repr*(x: string): string {.noSideEffect.} =
   ## repr for a string argument. Returns `x`
-  ## as it is. This operator is useful for generic code, so
-  ## that ``$expr`` also works if ``expr`` is already a string.
+  ## but quoted.
+  '"' & x & '"'
 
 proc repr*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect.}
   ## repr for an enumeration argument. This works for
diff --git a/tests/arc/trepr.nim b/tests/arc/trepr.nim
index e24c112ac..a870b40b7 100644
--- a/tests/arc/trepr.nim
+++ b/tests/arc/trepr.nim
@@ -7,8 +7,8 @@ nil
   output: '''
 nil
 2
-Obj(member: ref @[hello])
-ref (member: ref @[hello])
+Obj(member: ref @["hello"])
+ref (member: ref @["hello"])
 '''
 """
 import tables
diff --git a/tests/destructor/tfinalizer.nim b/tests/destructor/tfinalizer.nim
index 02a5cef7e..eb2cd09af 100644
--- a/tests/destructor/tfinalizer.nim
+++ b/tests/destructor/tfinalizer.nim
@@ -1,6 +1,6 @@
 discard """
   cmd: "nim c --gc:arc $file"
-  output: '''Foo(field: Dick Laurent, k: ka, x: 0.0)
+  output: '''Foo(field: "Dick Laurent", k: ka, x: 0.0)
 Nobody is dead
 Dick Laurent is dead'''
 """