cuelang.org/go@v0.10.1/cue/testdata/definitions/files.txtar (about) 1 // Treat fields of different files as belonging to the same struct. 2 // This means that a closed embedding in one file should not restrict the 3 // fields of another. 4 5 -- in.cue -- 6 package foo 7 8 #theme: { 9 color: string 10 ctermbg: string 11 } 12 dark: #theme & { 13 color: "dark" 14 ctermbg: "239" 15 } 16 light: #theme & { 17 color: "light" 18 ctermbg: "254" 19 } 20 #Config: { 21 console: dark | *light 22 } 23 -- box.cue -- 24 package foo 25 26 #Config & { 27 console: dark 28 } 29 -- out/eval/stats -- 30 Leaks: 0 31 Freed: 25 32 Reused: 19 33 Allocs: 6 34 Retain: 1 35 36 Unifications: 21 37 Conjuncts: 69 38 Disjuncts: 26 39 -- out/evalalpha -- 40 (#struct){ 41 console: (#struct){ 42 color: (string){ "dark" } 43 ctermbg: (string){ "239" } 44 } 45 #theme: (#struct){ 46 color: (string){ string } 47 ctermbg: (string){ string } 48 } 49 dark: (#struct){ 50 color: (string){ "dark" } 51 ctermbg: (string){ "239" } 52 } 53 light: (#struct){ 54 color: (string){ "light" } 55 ctermbg: (string){ "254" } 56 } 57 #Config: (#struct){ 58 console: (#struct){ |(*(#struct){ 59 color: (string){ "light" } 60 ctermbg: (string){ "254" } 61 }, (#struct){ 62 color: (string){ "dark" } 63 ctermbg: (string){ "239" } 64 }) } 65 } 66 } 67 -- diff/-out/evalalpha<==>+out/eval -- 68 diff old new 69 --- old 70 +++ new 71 @@ -1,4 +1,8 @@ 72 (#struct){ 73 + console: (#struct){ 74 + color: (string){ "dark" } 75 + ctermbg: (string){ "239" } 76 + } 77 #theme: (#struct){ 78 color: (string){ string } 79 ctermbg: (string){ string } 80 @@ -20,8 +24,4 @@ 81 ctermbg: (string){ "239" } 82 }) } 83 } 84 - console: (#struct){ 85 - color: (string){ "dark" } 86 - ctermbg: (string){ "239" } 87 - } 88 } 89 -- diff/todo/p3 -- 90 Reordering. 91 -- out/eval -- 92 (#struct){ 93 #theme: (#struct){ 94 color: (string){ string } 95 ctermbg: (string){ string } 96 } 97 dark: (#struct){ 98 color: (string){ "dark" } 99 ctermbg: (string){ "239" } 100 } 101 light: (#struct){ 102 color: (string){ "light" } 103 ctermbg: (string){ "254" } 104 } 105 #Config: (#struct){ 106 console: (#struct){ |(*(#struct){ 107 color: (string){ "light" } 108 ctermbg: (string){ "254" } 109 }, (#struct){ 110 color: (string){ "dark" } 111 ctermbg: (string){ "239" } 112 }) } 113 } 114 console: (#struct){ 115 color: (string){ "dark" } 116 ctermbg: (string){ "239" } 117 } 118 } 119 -- out/compile -- 120 --- box.cue 121 { 122 (〈0;#Config〉 & { 123 console: 〈1;dark〉 124 }) 125 } 126 --- in.cue 127 { 128 #theme: { 129 color: string 130 ctermbg: string 131 } 132 dark: (〈0;#theme〉 & { 133 color: "dark" 134 ctermbg: "239" 135 }) 136 light: (〈0;#theme〉 & { 137 color: "light" 138 ctermbg: "254" 139 }) 140 #Config: { 141 console: (〈1;dark〉|*〈1;light〉) 142 } 143 }