github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/cue/testdata/compile/labels.txtar (about) 1 -- in.cue -- 2 package compile 3 4 import "list" 5 6 dis1: "dev" | "prd" 7 dis2: *"dev" | "prd" 8 9 con1: string 10 let con2 = string 11 12 ok0: [string]: string 13 ok1: [name=string]: string 14 ok2: [con1]: string 15 ok3: [con2]: string 16 ok4: ["foo"]: string 17 ok5: [1]: string // disallowed in evaluator 18 ok6: [name=1]: string // disallowed in evaluator 19 ok7: [dis1]: string 20 ok8: [dis2]: string 21 ok9: [name=dis2]: string 22 ok10: [{foo: "bar"}]: string // disallowed in evaluator 23 ok11: [list.FlattenN([string], 1)]: string // disallowed in evaluator 24 25 bad1: [ for x in [1, 2, 3] {x}]: string 26 27 disallowTopAsLabel: { 28 _: 1 29 a: _ // Should not compile to a reference. 30 } 31 32 // TODO: disallow dollar as label? This is according to the spec, but it 33 // will be a breaking change and $ was reserved for referring to the root of 34 // a file, which we very likely will never implement. 35 // disallowDollarAsLabel: { 36 // $: 1 37 // } 38 39 saneReferencesInComprehensions: { 40 for _ in [1] { 41 a: _ // Should not compile to a reference. 42 } 43 } 44 -- out/compile -- 45 bad1: comprehension values not allowed in this position: 46 ./in.cue:24:9 47 disallowTopAsLabel: cannot use _ as label: 48 ./in.cue:27:2 49 --- in.cue 50 { 51 dis1: ("dev"|"prd") 52 dis2: (*"dev"|"prd") 53 con1: string 54 ok0: { 55 [string]: string 56 } 57 ok1: { 58 [string]: string 59 } 60 ok2: { 61 [〈1;con1〉]: string 62 } 63 ok3: { 64 [〈1;let con2〉]: string 65 } 66 ok4: { 67 ["foo"]: string 68 } 69 ok5: { 70 [1]: string 71 } 72 ok6: { 73 [1]: string 74 } 75 ok7: { 76 [〈1;dis1〉]: string 77 } 78 ok8: { 79 [〈1;dis2〉]: string 80 } 81 ok9: { 82 [〈1;dis2〉]: string 83 } 84 ok10: { 85 [{ 86 foo: "bar" 87 }]: string 88 } 89 ok11: { 90 [〈import;list〉.FlattenN([ 91 string, 92 ], 1)]: string 93 } 94 bad1: { 95 [_|_(comprehension values not allowed in this position)]: string 96 } 97 disallowTopAsLabel: { 98 _|_(cannot use _ as label) 99 a: _ 100 } 101 saneReferencesInComprehensions: { 102 for _, _ in [ 103 1, 104 ] { 105 a: _ 106 } 107 } 108 } 109 -- out/eval -- 110 bad1: comprehension values not allowed in this position: 111 ./in.cue:24:9 112 disallowTopAsLabel: cannot use _ as label: 113 ./in.cue:27:2