...
1-- in.cue --
2circularIf: {
3 #list: {
4 tail: #list | *null
5 if tail != null {
6 }
7 }
8}
9
10circularFor: {
11 #list: {
12 tail: #list | *null
13 for x in tail != null {
14 }
15 }
16}
17
18// Print a bit more sensible error message than "empty disjunction" here.
19// Issue #465
20userError: {
21 a: string | *_|_
22 if a != "" {
23 }
24}
25
26intField: {
27 for i, _ in [1, 2] {
28 (i): {
29 }
30 }
31}
32
33// Issue #2403
34conflictRangingOverSelf: {
35 x: {
36 name: string
37 age: int
38 }
39
40 x: {
41 for k, _ in x {
42 (k): k
43 }
44 }
45}
46-- out/eval/stats --
47Leaks: 1
48Freed: 28
49Reused: 22
50Allocs: 7
51Retain: 1
52
53Unifications: 19
54Conjuncts: 40
55Disjuncts: 29
56-- out/eval --
57Errors:
58conflictRangingOverSelf.x.age: conflicting values int and "age" (mismatched types int and string):
59 ./in.cue:36:9
60 ./in.cue:40:3
61 ./in.cue:41:9
62circularFor.#list: cannot range over tail != null (found bool, want list or struct):
63 ./in.cue:12:12
64intField: integer fields not supported:
65 ./in.cue:27:4
66
67Result:
68(_|_){
69 // [eval]
70 circularIf: (struct){
71 #list: (#struct){
72 tail: ((null|struct)){ |(*(null){ null }, (#struct){
73 tail: (null){ null }
74 }) }
75 }
76 }
77 circularFor: (_|_){
78 // [eval]
79 #list: (_|_){
80 // [eval] circularFor.#list: cannot range over tail != null (found bool, want list or struct):
81 // ./in.cue:12:12
82 tail: (null){ null }
83 }
84 }
85 userError: (_|_){
86 // [incomplete] userError: non-concrete value string in operand to !=:
87 // ./in.cue:21:5
88 // ./in.cue:20:5
89 a: (string){ string }
90 }
91 intField: (_|_){
92 // [eval] intField: integer fields not supported:
93 // ./in.cue:27:4
94 0: (struct){
95 }
96 1: (struct){
97 }
98 }
99 conflictRangingOverSelf: (_|_){
100 // [eval]
101 x: (_|_){
102 // [eval]
103 name: (string){ "name" }
104 age: (_|_){
105 // [eval] conflictRangingOverSelf.x.age: conflicting values int and "age" (mismatched types int and string):
106 // ./in.cue:36:9
107 // ./in.cue:40:3
108 // ./in.cue:41:9
109 }
110 }
111 }
112}
113-- out/compile --
114--- in.cue
115{
116 circularIf: {
117 #list: {
118 tail: (〈1;#list〉|*null)
119 if (〈0;tail〉 != null) {}
120 }
121 }
122 circularFor: {
123 #list: {
124 tail: (〈1;#list〉|*null)
125 for _, x in (〈0;tail〉 != null) {}
126 }
127 }
128 userError: {
129 a: (string|*_|_(explicit error (_|_ literal) in source))
130 if (〈0;a〉 != "") {}
131 }
132 intField: {
133 for i, _ in [
134 1,
135 2,
136 ] {
137 〈1;i〉: {}
138 }
139 }
140 conflictRangingOverSelf: {
141 x: {
142 name: string
143 age: int
144 }
145 x: {
146 for k, _ in 〈1;x〉 {
147 〈1;k〉: 〈1;k〉
148 }
149 }
150 }
151}
View as plain text