Fix distinct requiresInit test and manual (#19901)
fix distinct test and manual
This commit is contained in:
parent
3cb2d7af05
commit
caf6aff06b
2 changed files with 10 additions and 7 deletions
|
|
@ -2851,7 +2851,10 @@ Given the following distinct type definitions:
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
type
|
type
|
||||||
DistinctObject {.requiresInit, borrow: `.`.} = distinct MyObject
|
Foo = object
|
||||||
|
x: string
|
||||||
|
|
||||||
|
DistinctFoo {.requiresInit, borrow: `.`.} = distinct Foo
|
||||||
DistinctString {.requiresInit.} = distinct string
|
DistinctString {.requiresInit.} = distinct string
|
||||||
|
|
||||||
The following code blocks will fail to compile:
|
The following code blocks will fail to compile:
|
||||||
|
|
@ -2864,7 +2867,7 @@ The following code blocks will fail to compile:
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
var s: DistinctString
|
var s: DistinctString
|
||||||
s = "test"
|
s = "test"
|
||||||
doAssert s == "test"
|
doAssert string(s) == "test"
|
||||||
|
|
||||||
But these ones will compile successfully:
|
But these ones will compile successfully:
|
||||||
|
|
||||||
|
|
@ -2873,8 +2876,8 @@ But these ones will compile successfully:
|
||||||
doAssert foo.x == "test"
|
doAssert foo.x == "test"
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
let s = "test"
|
let s = DistinctString("test")
|
||||||
doAssert s == "test"
|
doAssert string(s) == "test"
|
||||||
|
|
||||||
Let statement
|
Let statement
|
||||||
-------------
|
-------------
|
||||||
|
|
|
||||||
|
|
@ -135,11 +135,11 @@ block tRequiresInit:
|
||||||
reject:
|
reject:
|
||||||
var s: DistinctString
|
var s: DistinctString
|
||||||
s = "test"
|
s = "test"
|
||||||
doAssert s == "test"
|
doAssert string(s) == "test"
|
||||||
|
|
||||||
accept:
|
accept:
|
||||||
let s = "test"
|
let s = DistinctString("test")
|
||||||
doAssert s == "test"
|
doAssert string(s) == "test"
|
||||||
|
|
||||||
block: #17322
|
block: #17322
|
||||||
type
|
type
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue