blob: d61ff6dc009aaa7cde2ee115b49443e2fb665f32 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
discard """
output: '''x
[10, 11, 12, 13]'''
"""
# bug #14805
type Foo = object
a: string
proc bar(f: var Foo): lent string =
result = f.a
var foo = Foo(a: "x")
echo bar(foo)
# bug #14878
# proc byLentImpl[T](a: T): lent T = a
proc byLentVar[T](a: var T): lent T =
result = a
# result = a.byLentImpl # this doesn't help
var x = 3 # error: cannot take the address of an rvalue of type 'NI *'
var xs = [10,11,12,13] # SIGSEGV
let x2 = x.byLentVar
let xs2 = xs.byLentVar
echo xs2
# bug #22138
type Xxx = object
type
Opt[T] = object
case oResultPrivate*: bool
of false:
discard
of true:
vResultPrivate*: T
func value*[T: not void](self: Opt[T]): lent T {.inline.} =
self.vResultPrivate
template get*[T: not void](self: Opt[T]): T = self.value()
method connect*(
self: Opt[(int, int)]) =
discard self.get()[0]
|