cuelang.org/go@v0.13.0/cue/testdata/eval/issue2337.txtar (about) 1 -- in.cue -- 2 // evalv2 failed with the confusing error "x: was already used" 3 // rather than a friendlier "conflicting values" error. 4 simple: { 5 x: "x" 6 (x): "foo" 7 } 8 9 // Worked on CUE v0.5.0, broke on v0.6.0 with "was already used". 10 // Should succeed, as the comprehension does not change env2. 11 issue2473: one: { 12 c: { 13 env: "prod" 14 env: "dev" | "prod" 15 env2: env 16 } 17 18 if c.env2 == "prod" { 19 { 20 c: env2: string 21 example: c.env2 22 } 23 } 24 } 25 // A variant of the above which failed on v0.5.0 as well. 26 issue2473: two: { 27 env: "prod" 28 env: "dev" | "prod" 29 env2: env 30 31 if env2 == "prod" { 32 { 33 env2: string 34 example: env2 35 } 36 } 37 } 38 -- out/compile -- 39 --- in.cue 40 { 41 simple: { 42 x: "x" 43 〈0;x〉: "foo" 44 } 45 issue2473: { 46 one: { 47 c: { 48 env: "prod" 49 env: ("dev"|"prod") 50 env2: 〈0;env〉 51 } 52 if (〈0;c〉.env2 == "prod") { 53 { 54 c: { 55 env2: string 56 } 57 example: 〈0;c〉.env2 58 } 59 } 60 } 61 } 62 issue2473: { 63 two: { 64 env: "prod" 65 env: ("dev"|"prod") 66 env2: 〈0;env〉 67 if (〈0;env2〉 == "prod") { 68 { 69 env2: string 70 example: 〈0;env2〉 71 } 72 } 73 } 74 } 75 } 76 -- out/eval/stats -- 77 Leaks: 2 78 Freed: 19 79 Reused: 13 80 Allocs: 8 81 Retain: 10 82 83 Unifications: 13 84 Conjuncts: 37 85 Disjuncts: 21 86 -- out/evalalpha -- 87 Errors: 88 simple.x: conflicting values "foo" and "x": 89 ./in.cue:4:7 90 ./in.cue:5:7 91 92 Result: 93 (_|_){ 94 // [eval] 95 simple: (_|_){ 96 // [eval] 97 x: (_|_){ 98 // [eval] simple.x: conflicting values "foo" and "x": 99 // ./in.cue:4:7 100 // ./in.cue:5:7 101 } 102 } 103 issue2473: (struct){ 104 one: (struct){ 105 c: (struct){ 106 env: (string){ "prod" } 107 env2: (string){ "prod" } 108 } 109 example: (string){ "prod" } 110 } 111 two: (struct){ 112 env: (string){ "prod" } 113 env2: (string){ "prod" } 114 example: (string){ "prod" } 115 } 116 } 117 } 118 -- diff/-out/evalalpha<==>+out/eval -- 119 diff old new 120 --- old 121 +++ new 122 @@ -1,25 +1,28 @@ 123 -(struct){ 124 +Errors: 125 +simple.x: conflicting values "foo" and "x": 126 + ./in.cue:4:7 127 + ./in.cue:5:7 128 + 129 +Result: 130 +(_|_){ 131 + // [eval] 132 simple: (_|_){ 133 - // [incomplete] simple: cannot add field x: was already used: 134 - // ./in.cue:5:2 135 - x: (string){ "x" } 136 + // [eval] 137 + x: (_|_){ 138 + // [eval] simple.x: conflicting values "foo" and "x": 139 + // ./in.cue:4:7 140 + // ./in.cue:5:7 141 + } 142 } 143 issue2473: (struct){ 144 one: (struct){ 145 - c: (_|_){ 146 - // [incomplete] issue2473.one: cannot add field env2: was already used: 147 - // ./in.cue:19:7 148 + c: (struct){ 149 env: (string){ "prod" } 150 env2: (string){ "prod" } 151 } 152 - example: (_|_){ 153 - // [incomplete] issue2473.one: cannot add field env2: was already used: 154 - // ./in.cue:19:7 155 - } 156 - } 157 - two: (_|_){ 158 - // [incomplete] issue2473.two: cannot add field env2: was already used: 159 - // ./in.cue:32:4 160 + example: (string){ "prod" } 161 + } 162 + two: (struct){ 163 env: (string){ "prod" } 164 env2: (string){ "prod" } 165 example: (string){ "prod" } 166 -- out/eval -- 167 (struct){ 168 simple: (_|_){ 169 // [incomplete] simple: cannot add field x: was already used: 170 // ./in.cue:5:2 171 x: (string){ "x" } 172 } 173 issue2473: (struct){ 174 one: (struct){ 175 c: (_|_){ 176 // [incomplete] issue2473.one: cannot add field env2: was already used: 177 // ./in.cue:19:7 178 env: (string){ "prod" } 179 env2: (string){ "prod" } 180 } 181 example: (_|_){ 182 // [incomplete] issue2473.one: cannot add field env2: was already used: 183 // ./in.cue:19:7 184 } 185 } 186 two: (_|_){ 187 // [incomplete] issue2473.two: cannot add field env2: was already used: 188 // ./in.cue:32:4 189 env: (string){ "prod" } 190 env2: (string){ "prod" } 191 example: (string){ "prod" } 192 } 193 } 194 }