github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/cue/testdata/definitions/issue359.txtar (about) 1 -- in.cue -- 2 #simple: { 3 peso: *1 | int 4 edad: *2 | int 5 } 6 7 // Second struct is not considered closed, as expected 8 good: #simple & { 9 peso: 4 10 } 11 12 #complex: { 13 things: [string]: #simple 14 } 15 16 // Still, no closedness issue in the second struct 17 #many: #complex & { 18 things: hola: peso: 2 19 things: sol: peso: 3 20 } 21 22 // Inner struct in second struct IS considered closed: why? 23 bad: #many & { 24 things: hola: peso: 2 25 } 26 27 // non-definition equivalent 28 many: #complex & { 29 things: hola: peso: 2 30 things: sol: peso: 3 31 } 32 33 // Now inner struct on second struct is NOT considered closed 34 notbad: many & { 35 things: hola: peso: 2 36 } 37 -- out/eval -- 38 (struct){ 39 #simple: (#struct){ 40 peso: (int){ |(*(int){ 1 }, (int){ int }) } 41 edad: (int){ |(*(int){ 2 }, (int){ int }) } 42 } 43 good: (#struct){ 44 peso: (int){ 4 } 45 edad: (int){ |(*(int){ 2 }, (int){ int }) } 46 } 47 #complex: (#struct){ 48 things: (#struct){ 49 } 50 } 51 #many: (#struct){ 52 things: (#struct){ 53 hola: (#struct){ 54 peso: (int){ 2 } 55 edad: (int){ |(*(int){ 2 }, (int){ int }) } 56 } 57 sol: (#struct){ 58 peso: (int){ 3 } 59 edad: (int){ |(*(int){ 2 }, (int){ int }) } 60 } 61 } 62 } 63 bad: (#struct){ 64 things: (#struct){ 65 hola: (#struct){ 66 peso: (int){ 2 } 67 edad: (int){ |(*(int){ 2 }, (int){ int }) } 68 } 69 sol: (#struct){ 70 peso: (int){ 3 } 71 edad: (int){ |(*(int){ 2 }, (int){ int }) } 72 } 73 } 74 } 75 many: (#struct){ 76 things: (#struct){ 77 hola: (#struct){ 78 peso: (int){ 2 } 79 edad: (int){ |(*(int){ 2 }, (int){ int }) } 80 } 81 sol: (#struct){ 82 peso: (int){ 3 } 83 edad: (int){ |(*(int){ 2 }, (int){ int }) } 84 } 85 } 86 } 87 notbad: (#struct){ 88 things: (#struct){ 89 hola: (#struct){ 90 peso: (int){ 2 } 91 edad: (int){ |(*(int){ 2 }, (int){ int }) } 92 } 93 sol: (#struct){ 94 peso: (int){ 3 } 95 edad: (int){ |(*(int){ 2 }, (int){ int }) } 96 } 97 } 98 } 99 } 100 -- out/compile -- 101 --- in.cue 102 { 103 #simple: { 104 peso: (*1|int) 105 edad: (*2|int) 106 } 107 good: (〈0;#simple〉 & { 108 peso: 4 109 }) 110 #complex: { 111 things: { 112 [string]: 〈2;#simple〉 113 } 114 } 115 #many: (〈0;#complex〉 & { 116 things: { 117 hola: { 118 peso: 2 119 } 120 } 121 things: { 122 sol: { 123 peso: 3 124 } 125 } 126 }) 127 bad: (〈0;#many〉 & { 128 things: { 129 hola: { 130 peso: 2 131 } 132 } 133 }) 134 many: (〈0;#complex〉 & { 135 things: { 136 hola: { 137 peso: 2 138 } 139 } 140 things: { 141 sol: { 142 peso: 3 143 } 144 } 145 }) 146 notbad: (〈0;many〉 & { 147 things: { 148 hola: { 149 peso: 2 150 } 151 } 152 }) 153 }