File: 047_struct_comprehensions.txtar

package info (click to toggle)
golang-github-cue-lang-cue 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,644 kB
  • sloc: makefile: 20; sh: 15
file content (103 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#name: struct comprehensions
#evalPartial
-- in.cue --
obj: foo: a: "bar"
obj: [Name=string]: {
	a: *"dummy" | string
	if true {
		sub: as: a
	}
}

for k, v in {#def: 1, opt?: 2, _hid: 3, reg: 4} {
	"\(k)": v
}
-- out/def --
obj: {
	{[Name=string]: {
		a: *"dummy" | string, sub: {
			as: a
		}
	}}
	foo: {
		a: "bar"
		sub: {
			as: "bar"
		}
	}
}
reg: 4
-- out/export --
obj: {
	foo: {
		a: "bar"
		sub: {
			as: "bar"
		}
	}
}
reg: 4
-- out/yaml --
obj:
  foo:
    a: bar
    sub:
      as: bar
reg: 4
-- out/json --
{"obj":{"foo":{"a":"bar","sub":{"as":"bar"}}},"reg":4}
-- out/legacy-debug --
<0>{obj: <1>{[]: <2>(Name: string)-><3>{a: (*"dummy" | string) if true yield <4>{sub: <5>{as: <3>.a}}}, foo: <6>{a: "bar", sub: <7>{as: "bar"}}}, reg: 4}
-- out/compile --
--- in.cue
{
  obj: {
    foo: {
      a: "bar"
    }
  }
  obj: {
    [string]: {
      a: (*"dummy"|string)
      if true {
        sub: {
          as: 〈2;a〉
        }
      }
    }
  }
  for k, v in {
    #def: 1
    opt?: 2
    _hid: 3
    reg: 4
  } {
    "\(〈1;k〉)": 〈1;v〉
  }
}
-- out/eval/stats --
Leaks:  2
Freed:  12
Reused: 7
Allocs: 7
Retain: 2

Unifications: 10
Conjuncts:    19
Disjuncts:    13

MisalignedConjunct: 5

NumCloseIDs: 2
-- out/eval --
(struct){
  obj: (struct){
    foo: (struct){
      a: (string){ "bar" }
      sub: (struct){
        as: (string){ "bar" }
      }
    }
  }
  reg: (int){ 4 }
}