github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/cue/testdata/definitions/hidden.txtar (about) 1 cue eval ./pkg:foo 2 3 -- cue.mod/module.cue -- 4 module: "example.com" 5 -- in.cue -- 6 package foo 7 8 import "example.com/pkg" 9 10 #def: { 11 _name: d: int 12 } 13 14 d: pkg.#D & {_name: d: int, _val: f: 4} 15 16 // TODO: this should fail, as the _name restricting it is in this 17 // package. 18 e: pkg.#D & #def & { 19 // This should fail as c is disallowed by the _name defined 20 // in this package 21 _name: c: int 22 23 // This should not fail, as this is a different _val 24 _val: g: int 25 } 26 27 f: pkg.#D & {_val: f: 4} 28 g: f._val 29 -- pkg/bar.cue -- 30 package pkg 31 32 #D: {_val: f: 3} 33 -- out/eval -- 34 Errors: 35 e._name: field not allowed: c: 36 ./in.cue:6:9 37 ./in.cue:13:13 38 ./in.cue:16:9 39 40 Result: 41 (_|_){ 42 // [eval] 43 #def: (#struct){ 44 _name(:foo): (#struct){ 45 d: (int){ int } 46 } 47 } 48 d: (#struct){ 49 _val(example.com/pkg): (#struct){ 50 f: (int){ 3 } 51 } 52 _name(:foo): (struct){ 53 d: (int){ int } 54 } 55 _val(:foo): (struct){ 56 f: (int){ 4 } 57 } 58 } 59 e: (_|_){ 60 // [eval] 61 _val(example.com/pkg): (#struct){ 62 f: (int){ 3 } 63 } 64 _name(:foo): (_|_){ 65 // [eval] 66 d: (int){ int } 67 c: (_|_){ 68 // [eval] e._name: field not allowed: c: 69 // ./in.cue:6:9 70 // ./in.cue:13:13 71 // ./in.cue:16:9 72 } 73 } 74 _val(:foo): (struct){ 75 g: (int){ int } 76 } 77 } 78 f: (#struct){ 79 _val(example.com/pkg): (#struct){ 80 f: (int){ 3 } 81 } 82 _val(:foo): (struct){ 83 f: (int){ 4 } 84 } 85 } 86 g: (struct){ 87 f: (int){ 4 } 88 } 89 } 90 -- out/compile -- 91 --- in.cue 92 { 93 #def: { 94 _name: { 95 d: int 96 } 97 } 98 d: (〈import;"example.com/pkg"〉.#D & { 99 _name: { 100 d: int 101 } 102 _val: { 103 f: 4 104 } 105 }) 106 e: ((〈import;"example.com/pkg"〉.#D & 〈0;#def〉) & { 107 _name: { 108 c: int 109 } 110 _val: { 111 g: int 112 } 113 }) 114 f: (〈import;"example.com/pkg"〉.#D & { 115 _val: { 116 f: 4 117 } 118 }) 119 g: 〈0;f〉._val 120 }