summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKhaled Hammouda <khaledh@gmail.com>2022-06-22 06:36:30 -0400
committerGitHub <noreply@github.com>2022-06-22 12:36:30 +0200
commitcaf6aff06b6dd36ef0bbe8c1f8b527952790e208 (patch)
treec172dad14234bd2ba20c386b28d55112275d0379
parent3cb2d7af0591b12044d4be20dfb6d7f7ff79a4ff (diff)
downloadNim-caf6aff06b6dd36ef0bbe8c1f8b527952790e208.tar.gz
Fix distinct requiresInit test and manual (#19901)
fix distinct test and manual
-rw-r--r--doc/manual.rst11
-rw-r--r--tests/distinct/tdistinct.nim6
2 files changed, 10 insertions, 7 deletions
diff --git a/doc/manual.rst b/doc/manual.rst
index 82c9f5758..b63a2f68f 100644
--- a/doc/manual.rst
+++ b/doc/manual.rst
@@ -2851,7 +2851,10 @@ Given the following distinct type definitions:
 
 .. code-block:: nim
   type
-    DistinctObject {.requiresInit, borrow: `.`.} = distinct MyObject
+    Foo = object
+      x: string
+
+    DistinctFoo {.requiresInit, borrow: `.`.} = distinct Foo
     DistinctString {.requiresInit.} = distinct string
 
 The following code blocks will fail to compile:
@@ -2864,7 +2867,7 @@ The following code blocks will fail to compile:
 .. code-block:: nim
   var s: DistinctString
   s = "test"
-  doAssert s == "test"
+  doAssert string(s) == "test"
 
 But these ones will compile successfully:
 
@@ -2873,8 +2876,8 @@ But these ones will compile successfully:
   doAssert foo.x == "test"
 
 .. code-block:: nim
-  let s = "test"
-  doAssert s == "test"
+  let s = DistinctString("test")
+  doAssert string(s) == "test"
 
 Let statement
 -------------
diff --git a/tests/distinct/tdistinct.nim b/tests/distinct/tdistinct.nim
index dd8237854..8ec083020 100644
--- a/tests/distinct/tdistinct.nim
+++ b/tests/distinct/tdistinct.nim
@@ -135,11 +135,11 @@ block tRequiresInit:
   reject:
     var s: DistinctString
     s = "test"
-    doAssert s == "test"
+    doAssert string(s) == "test"
 
   accept:
-    let s = "test"
-    doAssert s == "test"
+    let s = DistinctString("test")
+    doAssert string(s) == "test"
 
 block: #17322
   type