summary refs log tree commit diff stats
path: root/tests/implicit/timplicit.nim
blob: bb701249c0ee9a28056dff81fe584ce6cb564fe5 (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
discard """
  output: '''
1
2
3
4
2
88
timplicit done
'''
"""


for x in [1, 2, 3, 4]:
  echo x


type
  TValue* {.pure, final.} = object of RootObj
    a: int
  PValue = ref TValue
  PPValue = ptr PValue


var x: PValue
new x
var sp: PPValue = addr x

sp.a = 2
if sp.a == 2: echo 2  # with sp[].a the error is gone

# Test the new auto-deref a little

{.experimental.}

proc p(x: var int; y: int) = x += y

block:
  var x: ref int
  new(x)

  x.p(44)

  var indirect = p
  x.indirect(44)

  echo x[]

  echo "timplicit done"