summary refs log tree commit diff stats
path: root/tests/objects/tobjconstr2.nim
blob: 39683ddc5c935ee4a5b855da7e7b7dfa928cef69 (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
type TFoo{.exportc.} = object
 x:int

var s{.exportc.}: seq[TFoo] = @[]

s.add TFoo(x: 42)

echo s[0].x


# bug #563
type
  Foo =
    object {.inheritable.}
      x: int

  Bar =
    object of Foo
      y: int

var a = Bar(y: 100, x: 200) # works
var b = Bar(x: 100, y: 200) # used to fail

# bug 1275

type
  Graphic = object of TObject
    case kind: range[0..1]
    of 0:
      radius: float
    of 1:
      size: tuple[w, h: float]

var d = Graphic(kind: 1, size: (12.9, 6.9))

# bug #1274
type
  K = enum Koo, Kar
  Graphic2 = object of RootObj
    case kind: K
    of Koo:
      radius: float
    of Kar:
      size: tuple[w, h: float]

type NamedGraphic = object of Graphic2
  name: string

var ngr = NamedGraphic(kind: Koo, radius: 6.9, name: "Foo")
echo ngr.name