Skip to content

Commit

Permalink
Fix distinct requiresInit test and manual (#19901)
Browse files Browse the repository at this point in the history
fix distinct test and manual
  • Loading branch information
khaledh authored Jun 22, 2022
1 parent 3cb2d7a commit caf6aff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:

Expand All @@ -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
-------------
Expand Down
6 changes: 3 additions & 3 deletions tests/distinct/tdistinct.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit caf6aff

Please sign in to comment.