...
1-- in.cue --
2import mystrings "strings"
3
4@foo(bar)
5
6p1: [X=string]: name: X
7
8d1: "foo\(bar)": int
9bar: "bar"
10
11d2: C="foo\(bar)": {
12 name: "xx"
13 foo: C.name
14}
15
16// Issue #1910
17a: _
18comp: {
19 for k, v in [0]
20 let w = v {
21 "\(a)": w
22 "\(bar)": w
23 }
24}
25
26bytes: '\xeb \x1a\xf5\xaa\xf0\xd6\x06)'
27
28c1: mystrings.Contains("aa", "a")
29
30s1: """
31 multi
32 \(bar)
33 line
34 """
35
36l1: [3, ...int]
37l2: [...int]
38l3: []
39l4: [1, 2]
40l5: [1, 3] & {
41 [1, 3]
42
43 #foo: int
44}
45
46#foo: int
47l6: [1, #foo] & {
48 [1, 3]
49
50 #foo: int
51}
52
53n1: 1.0
54n10: 10
55
56// Ignored comment.
57
58// t is true
59t: true
60
61// Dangling comment.
62
63e1: <n1
64e2: >n1 & <n10
65e3: l4[2]
66e4: l4[2:3]
67e5: e1 + e2 - e3
68e6: !t
69e7: !t || !false
70e8?: !false
71
72m1: {[string]: uint} & {
73 // this is a pattern constraint
74 {[string]: int} & {[string]: int64}
75
76 // foo is an optional field
77 foo?: 3
78
79 // Dangling comment.
80
81 // bar is a field
82 bar: 4
83
84 // baz is a required field.
85 baz!: 5
86
87 // a comment too many.
88
89 ...
90}
91
92if true {
93 x: int
94}
95
96y1: {
97 src: [1, 2, 3]
98 for i, v in src for j, w in src if i < j {
99 "foo\(i)": v
100 "bar\(j)": w
101 }
102
103 for i, v in src {
104 "foo\(i)": v
105 }
106
107 x: [
108 for x in src
109 let y = x {
110 y
111 },
112 ]
113}
114
115preserveKeyFieldInComprehension: {
116 for _, s in [1] {
117 s
118 }
119}
120
121errorStructDef: {
122 a: 1
123 b: 1 & 2
124
125 #Def: 1
126}
127
128errorList: [
129 1,
130 1 & 2,
131]
132
133errorListDef: {
134 errorList
135
136 #Def: 1
137}
138-- out/definition --
139import mystrings "strings"
140
141@foo(bar)
142p1: {
143 [X=string]: {
144 name: X
145 }
146}
147d1: {
148 "foobar": int
149}
150bar: "bar"
151d2: {
152 C="foobar": {
153 name: "xx"
154 foo: C.name
155 }
156}
157
158// Issue #1910
159a: _
160comp: {
161 for k, v in [0]
162 let w = v {
163 "\(a)": w
164 "bar": w
165 }
166}
167bytes: '\xeb \x1a\xf5\xaa\xf0\xd6\x06)'
168c1: mystrings.Contains("aa", "a")
169s1: """
170 multi
171 \(bar)
172 line
173 """
174l1: [3, ...int]
175l2: [...int]
176l3: []
177l4: [1, 2]
178l5: [1, 3] & {
179 [1, 3]
180 #foo: int
181}
182#foo: int
183l6: [1, #foo] & {
184 [1, 3]
185 #foo: int
186}
187n1: 1.0
188n10: 10
189
190// t is true
191t: true
192e1: <n1
193e2: >n1 & <n10
194e3: l4[2]
195e4: l4[2:3]
196e5: e1 + e2 - e3
197e6: !t
198e7: !t || !false
199e8?: !false
200m1: {
201 [string]: int & >=0
202} & {
203 {
204 [string]: int
205 } & {
206 [string]: int64
207 }
208
209 // foo is an optional field
210 foo?: 3
211
212 // bar is a field
213 bar: 4
214
215 // baz is a required field.
216 baz!: 5
217 ...
218}
219
220if true {
221 x: int
222}
223y1: {
224 src: [1, 2, 3]
225 for i, v in src for j, w in src if i < j {
226 "foo\(i)": v
227 "bar\(j)": w
228 }
229
230 for i, v in src {
231 "foo\(i)": v
232 }
233 x: [
234 for x in src
235 let y = x {
236 y
237 }]
238}
239preserveKeyFieldInComprehension: {
240 for _, s in [1] {
241 s
242 }
243}
244errorStructDef: {
245 a: 1
246 b: _|_ // conflicting values 2 and 1
247 #Def: 1
248}
249errorList: [1, 1 & 2]
250errorListDef: {
251 errorList
252 #Def: 1
253}
254-- out/doc --
255[]
256[p1]
257[d1]
258[d1 foobar]
259[bar]
260[d2]
261[d2 foobar]
262[d2 foobar name]
263[d2 foobar foo]
264[a]
265- Issue #1910
266
267[comp]
268[comp bar]
269[bytes]
270[c1]
271[s1]
272[l1]
273[l1 0]
274[l2]
275[l3]
276[l4]
277[l4 0]
278[l4 1]
279[l5]
280[l5 #foo]
281[l5 0]
282[l5 1]
283[#foo]
284[l6]
285[l6 #foo]
286[l6 0]
287[l6 1]
288[n1]
289[n10]
290[t]
291- t is true
292
293[e1]
294[e2]
295[e3]
296[e4]
297[e5]
298[e6]
299[e7]
300[e8]
301[m1]
302[m1 foo]
303- foo is an optional field
304
305[m1 bar]
306- bar is a field
307
308[m1 baz]
309- baz is a required field.
310
311[x]
312[y1]
313[y1 src]
314[y1 src 0]
315[y1 src 1]
316[y1 src 2]
317[y1 x]
318[y1 x 0]
319[y1 x 1]
320[y1 x 2]
321[y1 foo0]
322[y1 bar1]
323[y1 bar2]
324[y1 foo1]
325[y1 foo2]
326[preserveKeyFieldInComprehension]
327[errorStructDef]
328[errorStructDef a]
329[errorStructDef b]
330[errorStructDef #Def]
331[errorList]
332[errorList 0]
333[errorList 1]
334[errorListDef]
335[errorListDef #Def]
336[errorListDef 0]
337[errorListDef 1]
338-- out/value --
339== Simplified
340_|_ // e3: index out of range [2] with length 2
341== Raw
342_|_ // e3: index out of range [2] with length 2
343== Final
344_|_ // e3: index out of range [2] with length 2
345== All
346{
347 @foo(bar)
348 p1: {}
349 d1: {
350 foobar: int
351 }
352 bar: "bar"
353 d2: {
354 foobar: {
355 name: "xx"
356 foo: "xx"
357 }
358 }
359
360 // Issue #1910
361 a: _
362 comp: {
363 for k, v in [0]
364 let w = v {
365 "\(a)": w
366 "bar": w
367 }
368 }
369 bytes: '\xeb \x1a\xf5\xaa\xf0\xd6\x06)'
370 c1: true
371 s1: """
372 multi
373 bar
374 line
375 """
376 l1: [3, ...int]
377 l2: [...int]
378 l3: []
379 l4: [1, 2]
380 l5: {
381 #foo: int
382 [1, 3]
383 }
384 #foo: int
385 l6: {
386 #foo: int
387 [1, 3]
388 }
389 n1: 1.0
390 n10: 10
391
392 // t is true
393 t: true
394 e1: <1.0
395 e2: >1.0 & <10
396 e3: _|_ // e3: index out of range [2] with length 2
397 e4: _|_ // e4: index 3 out of range
398 e5: _|_ // e3: index out of range [2] with length 2
399 e6: false
400 e7: true
401 e8?: true
402 m1: {
403 // foo is an optional field
404 foo?: 3
405
406 // bar is a field
407 bar: 4
408
409 // baz is a required field.
410 baz!: 5
411 }
412 y1: {
413 src: [1, 2, 3]
414 foo0: 1
415 bar1: 2
416 bar2: 3
417 foo1: 2
418 x: [1, 2, 3]
419 foo2: 3
420 }
421 preserveKeyFieldInComprehension: 1
422 errorStructDef: {
423 a: 1
424 b: _|_ // errorStructDef.b: conflicting values 2 and 1
425 #Def: 1
426 }
427 errorList: [1, _|_]
428 x: int
429 errorListDef: {
430 #Def: 1
431 [1, _|_]
432 }
433}
434== Eval
435_|_ // e3: index out of range [2] with length 2
View as plain text