github.com/solo-io/cue@v0.4.7/cue/testdata/disjunctions/specdeviation.txtar (about) 1 It turns out the semantics of the spec is somewhat awkward, 2 though theoretically nicer. It seems like we do need to change 3 the definition somewhat to make it less awkward, or at least 4 come up with a good workaround before adopting the spec. 5 6 We have introduce a small hack to mimic the old behavior for scalar 7 values. 8 9 Note that the value of p below is now 2 (default), but should 10 be the non-concrete 2 | int. 11 12 Proof: 13 p: *((*1 | int) & 2) | int // substitution of both P conjuncts in p 14 p: *(*_|_ | 2) | int // U1: distribute conjuncts 15 p: *_|_ | 2 | int // M2: remove mark 16 p: 2 | int // value after removing default. 17 18 -- in.cue -- 19 20 Q: *1 | int 21 q: *Q | int // 1 as expected 22 23 P: *1 | int 24 P: 2 25 p: *P | int // now 2, but should be (2 | int), according to the spec: 26 27 // Here the inner default may not be used as it is masked by the outer default. 28 r: (*3 | (*1 | 2)) & (1 | 2) 29 30 // Here the inner default is used, as there are no defaults marked in the 31 // outer disjunction. 32 s: (3 | (*1 | 2)) & (1 | 2) 33 34 s1: #Size & { min: 5 } 35 36 #Size : { 37 max: >min | *min 38 res: uint | * 0 39 min: >res | *(1 + res) 40 } 41 42 staged: { 43 c: ("a" | "b") & (*(*"a" | string) | string) 44 d: (*(*"a" | string) | string) & ("a" | "b") 45 } 46 47 issue763a: { 48 #A: { 49 v: "a" | "b" | "c" // change to string to fix 50 } 51 52 h: [string]: #A 53 54 h: [=~"^b"]: #A & { 55 v: *h.a.v | string 56 } 57 58 h: a: { 59 v: *"a" | string 60 } 61 62 h: baa: _ 63 h: boo: _ 64 } 65 66 -- out/eval -- 67 (struct){ 68 Q: (int){ |(*(int){ 1 }, (int){ int }) } 69 q: (int){ |(*(int){ 1 }, (int){ int }) } 70 P: (int){ 2 } 71 p: (int){ |(*(int){ 2 }, (int){ int }) } 72 r: (int){ |((int){ 1 }, (int){ 2 }) } 73 s: (int){ |(*(int){ 1 }, (int){ 2 }) } 74 s1: (#struct){ 75 max: (number){ |(*(int){ 5 }, (number){ >5 }) } 76 res: (int){ |(*(int){ 0 }, (int){ &(>=0, int) }) } 77 min: (int){ 5 } 78 } 79 #Size: (#struct){ 80 max: (number){ |(*(int){ 1 }, (number){ >0 }, (number){ >1 }) } 81 res: (int){ |(*(int){ 0 }, (int){ &(>=0, int) }) } 82 min: (number){ |(*(int){ 1 }, (number){ >0 }) } 83 } 84 staged: (struct){ 85 c: (string){ |(*(string){ "a" }, (string){ "b" }) } 86 d: (string){ |(*(string){ "a" }, (string){ "b" }) } 87 } 88 issue763a: (struct){ 89 #A: (#struct){ 90 v: (string){ |((string){ "a" }, (string){ "b" }, (string){ "c" }) } 91 } 92 h: (struct){ 93 a: (#struct){ 94 v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 95 } 96 baa: (#struct){ 97 v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 98 } 99 boo: (#struct){ 100 v: (string){ |(*(string){ "a" }, (string){ "b" }, (string){ "c" }) } 101 } 102 } 103 } 104 } 105 -- out/compile -- 106 --- in.cue 107 { 108 Q: (*1|int) 109 q: (*〈0;Q〉|int) 110 P: (*1|int) 111 P: 2 112 p: (*〈0;P〉|int) 113 r: ((*3|(*1|2)) & (1|2)) 114 s: ((3|(*1|2)) & (1|2)) 115 s1: (〈0;#Size〉 & { 116 min: 5 117 }) 118 #Size: { 119 max: (>〈0;min〉|*〈0;min〉) 120 res: (&(int, >=0)|*0) 121 min: (>〈0;res〉|*(1 + 〈0;res〉)) 122 } 123 staged: { 124 c: (("a"|"b") & (*(*"a"|string)|string)) 125 d: ((*(*"a"|string)|string) & ("a"|"b")) 126 } 127 issue763a: { 128 #A: { 129 v: ("a"|"b"|"c") 130 } 131 h: { 132 [string]: 〈1;#A〉 133 } 134 h: { 135 [=~"^b"]: (〈1;#A〉 & { 136 v: (*〈2;h〉.a.v|string) 137 }) 138 } 139 h: { 140 a: { 141 v: (*"a"|string) 142 } 143 } 144 h: { 145 baa: _ 146 } 147 h: { 148 boo: _ 149 } 150 } 151 }