forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skip structural generics instead, might be incorrect for C++ imports
- Loading branch information
Showing
6 changed files
with
78 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
discard """ | ||
output: ''' | ||
int | ||
float | ||
''' | ||
""" | ||
|
||
# issue #22479 | ||
|
||
type Obj[T] = object | ||
|
||
proc `=destroy`[T](self: var Obj[T]) = | ||
echo T | ||
|
||
block: | ||
let intObj = Obj[int]() | ||
|
||
block: | ||
let floatObj = Obj[float]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
discard """ | ||
output: ''' | ||
created Phantom[system.float] with value 1 | ||
created Phantom[system.string] with value 2 | ||
created Phantom[system.byte] with value 3 | ||
destroyed Phantom[system.byte] with value 3 | ||
destroyed Phantom[system.string] with value 2 | ||
destroyed Phantom[system.float] with value 1 | ||
''' | ||
""" | ||
|
||
# issue #24374 | ||
|
||
type Phantom[T] = object | ||
value: int | ||
# markerField: T | ||
|
||
proc initPhantom[T](value: int): Phantom[T] = | ||
doAssert value >= 0 | ||
echo "created " & $Phantom[T] & " with value " & $value | ||
result = Phantom[T](value: value) | ||
|
||
proc `=wasMoved`[T](x: var Phantom[T]) = | ||
x.value = -1 | ||
|
||
proc `=destroy`[T](x: Phantom[T]) = | ||
if x.value >= 0: | ||
echo "destroyed " & $Phantom[T] & " with value " & $x.value | ||
|
||
let | ||
x = initPhantom[float](1) | ||
y = initPhantom[string](2) | ||
z = initPhantom[byte](3) |