this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: add tests to fix 2481

Issue #2481

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I42ec5a594b3e8f759da952d3b1d5e7549e6a133b
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/557021
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+169
+169
cue/testdata/comprehensions/issue2481.txtar
··· 1 + 2 + -- in.cue -- 3 + // Mixing struct fields and embedded scalars should error. Using comprehensions 4 + // this follows a different path which may miss the error. 5 + // TODO: fix 6 + out: { 7 + for k in keys { 8 + if values[k] != _|_ { 9 + val: k 10 + if val != _|_ { 11 + k 12 + } 13 + } 14 + } 15 + } 16 + 17 + // multiple lets are mapped to the same location and will conflict. This is 18 + // fine, though, as lets do not represent a single data field. This should 19 + // therefore not error. 20 + // TODO: fix 21 + multiLets: { 22 + for k in keys { 23 + if values[k] != _|_ { 24 + let val = k 25 + if val != _|_ { 26 + k 27 + } 28 + } 29 + } 30 + } 31 + 32 + keys: [ 33 + // order matters 34 + "a", 35 + "b", 36 + ] 37 + 38 + values: { 39 + // order does not matter 40 + "b": "member" 41 + "c": "foo" 42 + } 43 + 44 + full: { 45 + out: { 46 + 47 + // changing this to a list of the keys "fixes" things, i.e. this comprehension is required 48 + for k, _ in #github_team_membership { 49 + 50 + // Remove this comprehension to trigger a different type of cycle error 51 + if ( values[k] != _|_ ) { 52 + 53 + // This let is also required 54 + let val = values[k] 55 + 56 + if val != null && ((val & string) != _|_) { 57 + (k): val 58 + } 59 + } 60 + } 61 + } 62 + 63 + #github_team_membership: { 64 + team_id: string 65 + role: string 66 + } 67 + 68 + values: { 69 + "role": "member" 70 + "username": "foo" 71 + } 72 + } 73 + -- out/eval/stats -- 74 + Leaks: 3 75 + Freed: 23 76 + Reused: 17 77 + Allocs: 9 78 + Retain: 57 79 + 80 + Unifications: 26 81 + Conjuncts: 48 82 + Disjuncts: 55 83 + -- out/eval -- 84 + (struct){ 85 + out: (_|_){ 86 + // [cycle] out: circular dependency in evaluation of conditionals: val changed after evaluation: 87 + // ./in.cue:8:7 88 + val: (string){ "b" } 89 + } 90 + multiLets: (_|_){ 91 + // [cycle] multiLets: circular dependency in evaluation of conditionals: val changed after evaluation: 92 + // ./in.cue:23:7 93 + } 94 + keys: (#list){ 95 + 0: (string){ "a" } 96 + 1: (string){ "b" } 97 + } 98 + values: (struct){ 99 + b: (string){ "member" } 100 + c: (string){ "foo" } 101 + } 102 + full: (struct){ 103 + out: (_|_){ 104 + // [cycle] full.out: circular dependency in evaluation of conditionals: (val & string) changed after evaluation: 105 + // ./in.cue:54:25 106 + role: (string){ "member" } 107 + } 108 + #github_team_membership: (#struct){ 109 + team_id: (string){ string } 110 + role: (string){ string } 111 + } 112 + values: (struct){ 113 + role: (string){ "member" } 114 + username: (string){ "foo" } 115 + } 116 + } 117 + } 118 + -- out/compile -- 119 + --- in.cue 120 + { 121 + out: { 122 + for _, k in 〈1;keys〉 { 123 + if (〈3;values〉[〈1;k〉] != _|_(explicit error (_|_ literal) in source)) { 124 + val: 〈2;k〉 125 + if (〈0;val〉 != _|_(explicit error (_|_ literal) in source)) { 126 + 〈3;k〉 127 + } 128 + } 129 + } 130 + } 131 + multiLets: { 132 + for _, k in 〈1;keys〉 { 133 + if (〈3;values〉[〈1;k〉] != _|_(explicit error (_|_ literal) in source)) { 134 + let val#1multi = 〈2;k〉 135 + if (〈0;let val#1〉 != _|_(explicit error (_|_ literal) in source)) { 136 + 〈3;k〉 137 + } 138 + } 139 + } 140 + } 141 + keys: [ 142 + "a", 143 + "b", 144 + ] 145 + values: { 146 + b: "member" 147 + c: "foo" 148 + } 149 + full: { 150 + out: { 151 + for k, _ in 〈1;#github_team_membership〉 { 152 + if (〈3;values〉[〈1;k〉] != _|_(explicit error (_|_ literal) in source)) { 153 + let val#2multi = 〈4;values〉[〈2;k〉] 154 + if ((〈0;let val#2〉 != null) && ((〈0;let val#2〉 & string) != _|_(explicit error (_|_ literal) in source))) { 155 + 〈3;k〉: 〈1;let val#2〉 156 + } 157 + } 158 + } 159 + } 160 + #github_team_membership: { 161 + team_id: string 162 + role: string 163 + } 164 + values: { 165 + role: "member" 166 + username: "foo" 167 + } 168 + } 169 + }