cuelang.org/go@v0.10.1/cue/testdata/cycle/builtins.txtar (about) 1 -- in.cue -- 2 import "regexp" 3 4 // Issue #655 5 // When evaluating a value into a struct, and then back into a value, the 6 // evaluation mode flips from Partial to AllConjunctsDone to Back. This is 7 // typically not an issue, but if a referred field is within a struct generated 8 // by a builtin, effectively the entire struct needs to be evaluated and special 9 // care should be taking to not evaluate too early. 10 builtinCyclePerm0: { 11 X: "mod.test" 12 13 Y: { 14 #components: regexp.FindNamedSubmatch(#"^(?P<host>[[:alnum:].]+)$"#, X) 15 host: #components.host 16 } 17 18 X: Y.host 19 } 20 21 builtinCyclePerm1: { 22 X: Y.host 23 24 Y: { 25 #components: regexp.FindNamedSubmatch(#"^(?P<host>[[:alnum:].]+)$"#, X) 26 host: #components.host 27 } 28 29 X: "mod.test" 30 } 31 32 builtinCyclePerm2: { 33 Y: { 34 #components: regexp.FindNamedSubmatch(#"^(?P<host>[[:alnum:].]+)$"#, X) 35 host: #components.host 36 } 37 38 X: Y.host 39 X: "mod.test" 40 } 41 42 builtinCyclePerm3: { 43 Y: { 44 #components: regexp.FindNamedSubmatch(#"^(?P<host>[[:alnum:].]+)$"#, X) 45 host: #components.host 46 } 47 48 X: "mod.test" 49 X: Y.host 50 } 51 52 builtinCyclePerm4: { 53 X: "mod.test" 54 X: Y.host 55 56 Y: { 57 #components: regexp.FindNamedSubmatch(#"^(?P<host>[[:alnum:].]+)$"#, X) 58 host: #components.host 59 } 60 } 61 62 builtinCyclePerm5: { 63 X: Y.host 64 X: "mod.test" 65 66 Y: { 67 #components: regexp.FindNamedSubmatch(#"^(?P<host>[[:alnum:].]+)$"#, X) 68 host: #components.host 69 } 70 } 71 -- out/eval/stats -- 72 Leaks: 0 73 Freed: 37 74 Reused: 30 75 Allocs: 7 76 Retain: 34 77 78 Unifications: 37 79 Conjuncts: 53 80 Disjuncts: 61 81 -- out/eval -- 82 (struct){ 83 builtinCyclePerm0: (struct){ 84 X: (string){ "mod.test" } 85 Y: (struct){ 86 #components: (#struct){ 87 host: (string){ "mod.test" } 88 } 89 host: (string){ "mod.test" } 90 } 91 } 92 builtinCyclePerm1: (struct){ 93 X: (string){ "mod.test" } 94 Y: (struct){ 95 #components: (#struct){ 96 host: (string){ "mod.test" } 97 } 98 host: (string){ "mod.test" } 99 } 100 } 101 builtinCyclePerm2: (struct){ 102 Y: (struct){ 103 #components: (#struct){ 104 host: (string){ "mod.test" } 105 } 106 host: (string){ "mod.test" } 107 } 108 X: (string){ "mod.test" } 109 } 110 builtinCyclePerm3: (struct){ 111 Y: (struct){ 112 #components: (#struct){ 113 host: (string){ "mod.test" } 114 } 115 host: (string){ "mod.test" } 116 } 117 X: (string){ "mod.test" } 118 } 119 builtinCyclePerm4: (struct){ 120 X: (string){ "mod.test" } 121 Y: (struct){ 122 #components: (#struct){ 123 host: (string){ "mod.test" } 124 } 125 host: (string){ "mod.test" } 126 } 127 } 128 builtinCyclePerm5: (struct){ 129 X: (string){ "mod.test" } 130 Y: (struct){ 131 #components: (#struct){ 132 host: (string){ "mod.test" } 133 } 134 host: (string){ "mod.test" } 135 } 136 } 137 } 138 -- out/compile -- 139 --- in.cue 140 { 141 builtinCyclePerm0: { 142 X: "mod.test" 143 Y: { 144 #components: 〈import;regexp〉.FindNamedSubmatch("^(?P<host>[[:alnum:].]+)$", 〈1;X〉) 145 host: 〈0;#components〉.host 146 } 147 X: 〈0;Y〉.host 148 } 149 builtinCyclePerm1: { 150 X: 〈0;Y〉.host 151 Y: { 152 #components: 〈import;regexp〉.FindNamedSubmatch("^(?P<host>[[:alnum:].]+)$", 〈1;X〉) 153 host: 〈0;#components〉.host 154 } 155 X: "mod.test" 156 } 157 builtinCyclePerm2: { 158 Y: { 159 #components: 〈import;regexp〉.FindNamedSubmatch("^(?P<host>[[:alnum:].]+)$", 〈1;X〉) 160 host: 〈0;#components〉.host 161 } 162 X: 〈0;Y〉.host 163 X: "mod.test" 164 } 165 builtinCyclePerm3: { 166 Y: { 167 #components: 〈import;regexp〉.FindNamedSubmatch("^(?P<host>[[:alnum:].]+)$", 〈1;X〉) 168 host: 〈0;#components〉.host 169 } 170 X: "mod.test" 171 X: 〈0;Y〉.host 172 } 173 builtinCyclePerm4: { 174 X: "mod.test" 175 X: 〈0;Y〉.host 176 Y: { 177 #components: 〈import;regexp〉.FindNamedSubmatch("^(?P<host>[[:alnum:].]+)$", 〈1;X〉) 178 host: 〈0;#components〉.host 179 } 180 } 181 builtinCyclePerm5: { 182 X: 〈0;Y〉.host 183 X: "mod.test" 184 Y: { 185 #components: 〈import;regexp〉.FindNamedSubmatch("^(?P<host>[[:alnum:].]+)$", 〈1;X〉) 186 host: 〈0;#components〉.host 187 } 188 } 189 }