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.
- Loading branch information
Showing
3 changed files
with
55 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
discard """ | ||
errormsg: "lent is only allowed in return type" | ||
""" | ||
|
||
# bug #16898 | ||
type | ||
Fp[N: static int, T] = object | ||
big: array[N, T] | ||
|
||
type | ||
QuadraticExt* = concept x | ||
## Quadratic Extension concept (like complex) | ||
type BaseField = auto | ||
x.c0 is BaseField | ||
x.c1 is BaseField | ||
|
||
{.experimental:"views".} | ||
|
||
func prod(r: var QuadraticExt, a, b: lent QuadraticExt) = | ||
discard | ||
|
||
type | ||
Fp2[N: static int, T] = object | ||
c0, c1: Fp[N, T] | ||
|
||
# This should be passed by reference, | ||
# but concepts do not respect the 24 bytes rule | ||
# or `byref` pragma. | ||
var r, a, b: Fp2[6, uint64] | ||
|
||
prod(r, a, b) |
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,15 @@ | ||
discard """ | ||
errormsg: "lent is only allowed in return type" | ||
""" | ||
|
||
# bug #17621 | ||
{.experimental: "views".} | ||
|
||
type Test = ref object | ||
foo: int | ||
|
||
proc modify(self: lent Test) = | ||
self.foo += 1 | ||
|
||
let test = Test(foo: 12) | ||
modify(test) |