summary refs log tree commit diff stats
path: root/tests/notnil/tmust_compile.nim
blob: d09dda0575bd5cb6904090de3e739672cd7fc3a1 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
discard """
  output: '''success'''
"""

# bug #6682
{.experimental: "notnil".}

type
    Fields = enum
        A=1, B, C

    Obj = object
        fld: array[Fields, int]

    AsGeneric[T] = array[Fields, T]
    Obj2[T] = object
      fld: AsGeneric[T]

var a: Obj # this works

var arr: array[Fields, int]

var b = Obj() # this doesn't (also doesn't works with additional fields)

var z = Obj2[int]()

echo "success"

# bug #6555

import tables

type
  TaskOrNil = ref object
  Task = TaskOrNil not nil

let table = newTable[string, Task]()
table.del("task")

# bug #6121

import json

type

  foo = object
    thing: ptr int not nil

  CTS = ref object
    subs_by_sid: Table[int, foo]


proc parse(cts: CTS, jn: JsonNode) =
  var y = jn.getInt(4523)
  let ces = foo(
    thing: addr y
  )

  cts.subs_by_sid[0] = ces


# bug #6489

proc p(x: proc(){.closure.} not nil) = discard
p(proc(){.closure.} = discard)