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