github.com/solo-io/cue@v0.4.7/cue/testdata/definitions/026_combined_definitions.txtar (about) 1 # DO NOT EDIT; generated by go run testdata/gen.go 2 # 3 #name: combined definitions 4 #evalPartial 5 -- in.cue -- 6 // Allow combining of structs within a definition 7 #D1: { 8 env: a: "A" 9 env: b: "B" 10 #def: {a: "A"} 11 #def: {b: "B"} 12 } 13 14 d1: #D1 & {env: c: "C"} 15 16 #D2: { 17 a: int 18 } 19 #D2: { 20 b: int 21 } 22 23 #D3: { 24 env: a: "A" 25 } 26 #D3: { 27 env: b: "B" 28 } 29 30 #D4: { 31 env: #DC 32 env: b: int 33 } 34 35 #DC: {a: int} 36 -- out/def -- 37 // Allow combining of structs within a definition 38 #D1: { 39 env: { 40 a: "A" 41 b: "B" 42 } 43 #def: { 44 a: "A" 45 b: "B" 46 } 47 } 48 d1: #D1 & { 49 env: { 50 c: "C" 51 } 52 } 53 #D2: { 54 a: int 55 b: int 56 } 57 #D3: { 58 env: { 59 a: "A" 60 b: "B" 61 } 62 } 63 #D4: { 64 env: _|_ // field "b" not allowed in closed struct 65 } 66 #DC: { 67 a: int 68 } 69 -- out/legacy-debug -- 70 <0>{#D1: <1>C{env: <2>C{a: "A", b: "B"}, #def: <3>C{a: "A", b: "B"}}, d1: <4>C{env: _|_("C":field "c" not allowed in closed struct), #def: <5>C{a: "A", b: "B"}}, #D2: <6>C{a: int, b: int}, #D3: <7>C{env: <8>C{a: "A", b: "B"}}, #D4: <9>C{env: _|_(int:field "b" not allowed in closed struct)}, #DC: <10>C{a: int}} 71 -- out/compile -- 72 --- in.cue 73 { 74 #D1: { 75 env: { 76 a: "A" 77 } 78 env: { 79 b: "B" 80 } 81 #def: { 82 a: "A" 83 } 84 #def: { 85 b: "B" 86 } 87 } 88 d1: (ă0;#D1ă & { 89 env: { 90 c: "C" 91 } 92 }) 93 #D2: { 94 a: int 95 } 96 #D2: { 97 b: int 98 } 99 #D3: { 100 env: { 101 a: "A" 102 } 103 } 104 #D3: { 105 env: { 106 b: "B" 107 } 108 } 109 #D4: { 110 env: ă1;#DCă 111 env: { 112 b: int 113 } 114 } 115 #DC: { 116 a: int 117 } 118 } 119 -- out/eval -- 120 Errors: 121 #D4.env: field not allowed: b: 122 ./in.cue:26:7 123 ./in.cue:27:7 124 ./in.cue:30:6 125 d1.env: field not allowed: c: 126 ./in.cue:3:7 127 ./in.cue:4:7 128 ./in.cue:9:5 129 ./in.cue:9:17 130 131 Result: 132 (_|_){ 133 // [eval] 134 #D1: (#struct){ 135 env: (#struct){ 136 a: (string){ "A" } 137 b: (string){ "B" } 138 } 139 #def: (#struct){ 140 a: (string){ "A" } 141 b: (string){ "B" } 142 } 143 } 144 d1: (_|_){ 145 // [eval] 146 env: (_|_){ 147 // [eval] 148 a: (string){ "A" } 149 b: (string){ "B" } 150 c: (_|_){ 151 // [eval] d1.env: field not allowed: c: 152 // ./in.cue:3:7 153 // ./in.cue:4:7 154 // ./in.cue:9:5 155 // ./in.cue:9:17 156 } 157 } 158 #def: (#struct){ 159 a: (string){ "A" } 160 b: (string){ "B" } 161 } 162 } 163 #D2: (#struct){ 164 a: (int){ int } 165 b: (int){ int } 166 } 167 #D3: (#struct){ 168 env: (#struct){ 169 a: (string){ "A" } 170 b: (string){ "B" } 171 } 172 } 173 #D4: (_|_){ 174 // [eval] 175 env: (_|_){ 176 // [eval] 177 a: (int){ int } 178 b: (_|_){ 179 // [eval] #D4.env: field not allowed: b: 180 // ./in.cue:26:7 181 // ./in.cue:27:7 182 // ./in.cue:30:6 183 } 184 } 185 } 186 #DC: (#struct){ 187 a: (int){ int } 188 } 189 }