github.com/solo-io/cue@v0.4.7/cue/testdata/disjunctions/defembed.txtar (about) 1 Interaction between defaults, embedding and disjunctions. 2 3 // TODO: at the moment, using a default will select it. 4 -- in.cue -- 5 x: { 6 // All of these resolve to *2 | 3 7 m1: (1 | (*2 | 3)) & (>=2 & <=3) 8 m2: (1 | (*2 | 3)) & (2 | 3) 9 m3: (*1 | *(*2 | 3)) & (2 | 3) 10 } 11 y1: x & { 12 {m4: x.m1+x.m2+x.m3} 13 } 14 y2: { 15 x 16 {m4: y2.m1+y2.m2+y2.m3} 17 } 18 Y=y3: { 19 x 20 {m4: Y.m1+Y.m2+Y.m3} 21 } 22 y4: x & { 23 {m4: y4.m1+y4.m2+y4.m3} 24 } 25 26 // Second disjunct in embedding is not possible because of previous declaration 27 // of `b`, so it should be resolved to {a: 1}. 28 b: (*"a" | "b") | "c" 29 {a: b} | {b: int} 30 31 -- out/eval -- 32 (struct){ 33 x: (struct){ 34 m1: (int){ |(*(int){ 2 }, (int){ 3 }) } 35 m2: (int){ |(*(int){ 2 }, (int){ 3 }) } 36 m3: (int){ |(*(int){ 2 }, (int){ 3 }) } 37 } 38 y1: (struct){ 39 m1: (int){ |(*(int){ 2 }, (int){ 3 }) } 40 m2: (int){ |(*(int){ 2 }, (int){ 3 }) } 41 m3: (int){ |(*(int){ 2 }, (int){ 3 }) } 42 m4: (int){ 6 } 43 } 44 y2: (struct){ 45 m1: (int){ |(*(int){ 2 }, (int){ 3 }) } 46 m2: (int){ |(*(int){ 2 }, (int){ 3 }) } 47 m3: (int){ |(*(int){ 2 }, (int){ 3 }) } 48 m4: (int){ 6 } 49 } 50 y3: (struct){ 51 m1: (int){ |(*(int){ 2 }, (int){ 3 }) } 52 m2: (int){ |(*(int){ 2 }, (int){ 3 }) } 53 m3: (int){ |(*(int){ 2 }, (int){ 3 }) } 54 m4: (int){ 6 } 55 } 56 y4: (struct){ 57 m1: (int){ |(*(int){ 2 }, (int){ 3 }) } 58 m2: (int){ |(*(int){ 2 }, (int){ 3 }) } 59 m3: (int){ |(*(int){ 2 }, (int){ 3 }) } 60 m4: (int){ 6 } 61 } 62 b: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 63 a: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 64 } 65 -- out/compile -- 66 --- in.cue 67 { 68 x: { 69 m1: ((1|(*2|3)) & (>=2 & <=3)) 70 m2: ((1|(*2|3)) & (2|3)) 71 m3: ((*1|*(*2|3)) & (2|3)) 72 } 73 y1: (〈0;x〉 & { 74 { 75 m4: ((〈2;x〉.m1 + 〈2;x〉.m2) + 〈2;x〉.m3) 76 } 77 }) 78 y2: { 79 〈1;x〉 80 { 81 m4: ((〈2;y2〉.m1 + 〈2;y2〉.m2) + 〈2;y2〉.m3) 82 } 83 } 84 y3: { 85 〈1;x〉 86 { 87 m4: ((〈2;y3〉.m1 + 〈2;y3〉.m2) + 〈2;y3〉.m3) 88 } 89 } 90 y4: (〈0;x〉 & { 91 { 92 m4: ((〈2;y4〉.m1 + 〈2;y4〉.m2) + 〈2;y4〉.m3) 93 } 94 }) 95 b: ((*"a"|"b")|"c") 96 ({ 97 a: 〈1;b〉 98 }|{ 99 b: int 100 }) 101 }