blob: 9813331f4f9541e04c64899c11290bb11e44f941 (
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
|
discard """
output: "yay"
cmd: "nim c --gc:arc $file"
"""
# bug #15122
import tables
type
BENodeKind* = enum
tkEof,
tkBytes,
tkList,
tkDict
BENode* = object
case kind: BENodeKind
of tkBytes: strVal: string
of tkList: listVal: seq[BENode]
of tkDict: dictVal*: Table[string, BENode]
else:
discard
proc unused(s: string): BENode =
# bad:
result = BENode(kind: tkBytes, strVal: "abc")
proc main =
var data = {
"examples": {
"values": BENode(
kind: tkList,
listVal: @[BENode(kind: tkBytes, strVal: "test")]
)
}.toTable()
}.toTable()
# For ARC listVal is empty for some reason
doAssert data["examples"]["values"].listVal[0].strVal == "test"
main()
echo "yay"
|