...
1-- in.cue --
2deployment: [string]: #Deployment
3
4deployment: foo: spec: replicas: 1
5
6#Deployment: {
7 #TypeMeta
8
9 spec: #Spec
10}
11
12#Spec: replicas: int
13
14#TypeMeta: {}
15
16recloseSimple: {
17 #foo: {}
18 a: {#foo} & {b: int}
19}
20
21// Reclosing
22reclose1: {
23 #D: {
24 x: int
25 y: int
26 }
27 #a: {
28 #D
29 b: {
30 c: int
31 }
32 }
33
34 z: #a.b
35 z: d: 3 // don't allow this
36}
37
38reclose2: {
39 #D: {
40 x: int
41 y: int
42 }
43 a: {
44 #D
45 b: {// keep open
46 c: int
47 }
48 }
49
50 z: a.b
51 z: d: 3 // allow this
52}
53
54reclose3: {
55 #Step: {
56 (#A | #B)
57 #Common
58 }
59 #Common: {
60 Name: string
61 }
62 #A: {
63 #Common
64 Something: int
65 }
66 #B: {
67 #Common
68 Else: int
69 }
70 x: #Step
71 x: #A & {
72 Name: "a"
73 Something: 4
74 }
75}
76-- out/eval/stats --
77Leaks: 0
78Freed: 63
79Reused: 56
80Allocs: 7
81Retain: 6
82
83Unifications: 59
84Conjuncts: 124
85Disjuncts: 69
86-- out/eval --
87Errors:
88reclose1.z.d: field not allowed:
89 ./in.cue:28:6
90 ./in.cue:33:5
91 ./in.cue:34:5
92recloseSimple.a.b: field not allowed:
93 ./in.cue:16:8
94 ./in.cue:17:5
95 ./in.cue:17:6
96 ./in.cue:17:15
97
98Result:
99(_|_){
100 // [eval]
101 deployment: (struct){
102 foo: (#struct){
103 spec: (#struct){
104 replicas: (int){ 1 }
105 }
106 }
107 }
108 #Deployment: (#struct){
109 spec: (#struct){
110 replicas: (int){ int }
111 }
112 }
113 #Spec: (#struct){
114 replicas: (int){ int }
115 }
116 #TypeMeta: (#struct){
117 }
118 recloseSimple: (_|_){
119 // [eval]
120 #foo: (#struct){
121 }
122 a: (_|_){
123 // [eval]
124 b: (_|_){
125 // [eval] recloseSimple.a.b: field not allowed:
126 // ./in.cue:16:8
127 // ./in.cue:17:5
128 // ./in.cue:17:6
129 // ./in.cue:17:15
130 }
131 }
132 }
133 reclose1: (_|_){
134 // [eval]
135 #D: (#struct){
136 x: (int){ int }
137 y: (int){ int }
138 }
139 #a: (#struct){
140 x: (int){ int }
141 y: (int){ int }
142 b: (#struct){
143 c: (int){ int }
144 }
145 }
146 z: (_|_){
147 // [eval]
148 c: (int){ int }
149 d: (_|_){
150 // [eval] reclose1.z.d: field not allowed:
151 // ./in.cue:28:6
152 // ./in.cue:33:5
153 // ./in.cue:34:5
154 }
155 }
156 }
157 reclose2: (struct){
158 #D: (#struct){
159 x: (int){ int }
160 y: (int){ int }
161 }
162 a: (#struct){
163 x: (int){ int }
164 y: (int){ int }
165 b: (struct){
166 c: (int){ int }
167 }
168 }
169 z: (struct){
170 c: (int){ int }
171 d: (int){ 3 }
172 }
173 }
174 reclose3: (struct){
175 #Step: (#struct){ |((#struct){
176 Name: (string){ string }
177 Something: (int){ int }
178 }, (#struct){
179 Name: (string){ string }
180 Else: (int){ int }
181 }) }
182 #Common: (#struct){
183 Name: (string){ string }
184 }
185 #A: (#struct){
186 Name: (string){ string }
187 Something: (int){ int }
188 }
189 #B: (#struct){
190 Name: (string){ string }
191 Else: (int){ int }
192 }
193 x: (#struct){
194 Name: (string){ "a" }
195 Something: (int){ 4 }
196 }
197 }
198}
199-- out/compile --
200--- in.cue
201{
202 deployment: {
203 [string]: 〈1;#Deployment〉
204 }
205 deployment: {
206 foo: {
207 spec: {
208 replicas: 1
209 }
210 }
211 }
212 #Deployment: {
213 〈1;#TypeMeta〉
214 spec: 〈1;#Spec〉
215 }
216 #Spec: {
217 replicas: int
218 }
219 #TypeMeta: {}
220 recloseSimple: {
221 #foo: {}
222 a: ({
223 〈1;#foo〉
224 } & {
225 b: int
226 })
227 }
228 reclose1: {
229 #D: {
230 x: int
231 y: int
232 }
233 #a: {
234 〈1;#D〉
235 b: {
236 c: int
237 }
238 }
239 z: 〈0;#a〉.b
240 z: {
241 d: 3
242 }
243 }
244 reclose2: {
245 #D: {
246 x: int
247 y: int
248 }
249 a: {
250 〈1;#D〉
251 b: {
252 c: int
253 }
254 }
255 z: 〈0;a〉.b
256 z: {
257 d: 3
258 }
259 }
260 reclose3: {
261 #Step: {
262 (〈1;#A〉|〈1;#B〉)
263 〈1;#Common〉
264 }
265 #Common: {
266 Name: string
267 }
268 #A: {
269 〈1;#Common〉
270 Something: int
271 }
272 #B: {
273 〈1;#Common〉
274 Else: int
275 }
276 x: 〈0;#Step〉
277 x: (〈0;#A〉 & {
278 Name: "a"
279 Something: 4
280 })
281 }
282}
View as plain text