mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 22:33:49 +00:00
Fix distinct requiresInit test and manual (#19901)
fix distinct test and manual
(cherry picked from commit caf6aff06b)
This commit is contained in:
committed by
narimiran
parent
67b94a96f7
commit
85e943db50
@@ -2893,7 +2893,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:
|
||||
@@ -2906,7 +2909,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:
|
||||
|
||||
@@ -2915,8 +2918,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
|
||||
-------------
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user