summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/system.nim10
-rw-r--r--lib/system/repr_v2.nim10
-rw-r--r--tests/stdlib/trepr.nim6
3 files changed, 14 insertions, 12 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 25133fca5..1bf1c5ccb 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2405,6 +2405,16 @@ when defined(nimV2):
   import system/repr_v2
   export repr_v2
 
+proc repr*[T, U](x: HSlice[T, U]): string =
+  ## Generic `repr` operator for slices that is lifted from the components
+  ## of `x`. Example:
+  ##
+  ## .. code-block:: Nim
+  ##  $(1 .. 5) == "1 .. 5"
+  result = repr(x.a)
+  result.add(" .. ")
+  result.add(repr(x.b))
+
 when hasAlloc or defined(nimscript):
   proc insert*(x: var string, item: string, i = 0.Natural) {.noSideEffect.} =
     ## Inserts `item` into `x` at position `i`.
diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim
index e9a6596fd..3a40ac5ad 100644
--- a/lib/system/repr_v2.nim
+++ b/lib/system/repr_v2.nim
@@ -177,16 +177,6 @@ proc repr*[T](x: seq[T]): string =
   ##   $(@[23, 45]) == "@[23, 45]"
   collectionToRepr(x, "@[", ", ", "]")
 
-proc repr*[T, U](x: HSlice[T, U]): string =
-  ## Generic `repr` operator for slices that is lifted from the components
-  ## of `x`. Example:
-  ##
-  ## .. code-block:: Nim
-  ##  $(1 .. 5) == "1 .. 5"
-  result = repr(x.a)
-  result.add(" .. ")
-  result.add(repr(x.b))
-
 proc repr*[T, IDX](x: array[IDX, T]): string =
   ## Generic `repr` operator for arrays that is lifted from the components.
   collectionToRepr(x, "[", ", ", "]")
diff --git a/tests/stdlib/trepr.nim b/tests/stdlib/trepr.nim
index a8c62ea55..3956b98f9 100644
--- a/tests/stdlib/trepr.nim
+++ b/tests/stdlib/trepr.nim
@@ -40,7 +40,7 @@ template main() =
   #[
   BUG:
   --gc:arc returns `"abc"`
-  regular gc returns with address, e.g. 0x1068aae60"abc", but only 
+  regular gc returns with address, e.g. 0x1068aae60"abc", but only
   for c,cpp backends (not js, vm)
   ]#
   block:
@@ -293,7 +293,7 @@ func fn2(): int =
 
       *a: b
       do: c
-    
+
     doAssert a == """foo(a, b, (c, d)):
   e
   f
@@ -322,5 +322,7 @@ else:
 do:
   c"""
 
+  doAssert repr(1..2) == "1 .. 2"
+
 static: main()
 main()