this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd/format: be consistent with whitespace in lists

Leading whitespace is not strictly enforced, but is incorrectly present
when the formatting of a list is fixed. The behaviour can be made
consistent by requesting no blanks at the start of a list.

```diff
-[ 1]
-[ for x in y {}]
+[1]
+ [for x in y {}]
```

Fixes #1023

Change-Id: I8a57461d99cf6fd67105ab01283906e8ee60fac8
Signed-off-by: Thomas Way <thomas@6f.io>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1171302
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

authored by

Thomas Way and committed by
Daniel Martí
d70007c1 8c826bcf

+164 -132
+1 -1
cmd/cue/cmd/eval.go
··· 42 42 Examples: 43 43 44 44 $ cat <<EOF > foo.cue 45 - a: [ "a", "b", "c" ] 45 + a: ["a", "b", "c"] 46 46 EOF 47 47 48 48 $ cue eval foo.cue -e a[0] -e a[2]
+1 -1
cmd/cue/cmd/root.go
··· 140 140 command: deploy: { 141 141 exec.Run 142 142 cmd: "kubectl" 143 - args: [ "-f", "deploy" ] 143 + args: ["-f", "deploy"] 144 144 in: json.Encode(userValue) // encode the emitted configuration. 145 145 } 146 146
+1 -1
cmd/cue/cmd/testdata/script/cmd_cycle.txtar
··· 99 99 } 100 100 101 101 command: print: cli.Print & { 102 - text: strings.Join([ for key, val in outputs { "key=\(key) val=\(val)" } ], "\n") 102 + text: strings.Join([for key, val in outputs { "key=\(key) val=\(val)" }], "\n") 103 103 } 104 104 105 105 -- stdout2397.golden --
+1 -1
cmd/cue/cmd/testdata/script/cmd_func.txtar
··· 8 8 9 9 x: y: 2 10 10 11 - objects: [ for v in [ json.Marshal(x) ] {v} ] 11 + objects: [for v in [json.Marshal(x)] {v}] 12 12 13 13 -- k_tool.cue -- 14 14 package kube
+2 -2
cmd/cue/cmd/testdata/script/cmd_issue2060.txtar
··· 118 118 Bindings: [ 119 119 for _, strokeDef in strokeDefs { 120 120 let bindingMap = strokeDef.Bindings["\(PlatformName)"] 121 - let bindingIds = [ for k, v in bindingMap {name: k, idx: v}] 121 + let bindingIds = [for k, v in bindingMap {name: k, idx: v}] 122 122 let bindingIdsSorted = list.Sort(bindingIds, {x: {}, y: {}, less: x.idx < y.idx}) 123 - let bindingKeys = [ for _, kv in bindingIdsSorted {kv.name}] 123 + let bindingKeys = [for _, kv in bindingIdsSorted {kv.name}] 124 124 let bindingText = strings.Join(bindingKeys, "+") 125 125 "DefText": "\(strokeDef.DefText)" 126 126 "BindText": bindingText
+1 -1
cmd/cue/cmd/testdata/script/eval_mixedfiletypes.txtar
··· 40 40 } 41 41 42 42 hasManager: { 43 - ok: len([ for m in team if list.Contains(m, "EM") {m}]) >= 1 43 + ok: len([for m in team if list.Contains(m, "EM") {m}]) >= 1 44 44 } 45 45 } 46 46 -- y.cue --
+1 -1
cmd/cue/cmd/testdata/script/help.txtar
··· 19 19 command: deploy: { 20 20 exec.Run 21 21 cmd: "kubectl" 22 - args: [ "-f", "deploy" ] 22 + args: ["-f", "deploy"] 23 23 in: json.Encode(userValue) // encode the emitted configuration. 24 24 } 25 25
+2 -2
cmd/cue/cmd/testdata/script/issue473.txtar
··· 10 10 11 11 Steps: [string]: #Step 12 12 13 - #TerminalName: or([ for k, _ in Terminals {k}]) 13 + #TerminalName: or([for k, _ in Terminals {k}]) 14 14 15 15 #Step: { 16 16 Terminal: #TerminalName ··· 33 33 Cmd: "ls" 34 34 } 35 35 } 36 - } 36 + }
+1 -1
cmd/cue/cmd/testdata/script/load_pkg.txtar
··· 61 61 bar: 3 62 62 -- sort/print.cue -- 63 63 files: {} 64 - flat: [ for k, _ in files {k} ] 64 + flat: [for k, _ in files {k}] 65 65 -- sort/root_1.cue -- 66 66 files: root_1: 0 67 67 -- sort/root_2/child_1.cue --
+1 -1
cmd/cue/cmd/testdata/script/merge_interaction.txtar
··· 16 16 "tool/cli" 17 17 ) 18 18 19 - objects: [ for x in map {x}] 19 + objects: [for x in map {x}] 20 20 21 21 command: dump: { 22 22 cli.Print & {
+1 -1
cue/format/node.go
··· 659 659 f.print(ws, x.Rbrace, token.RBRACE) 660 660 661 661 case *ast.ListLit: 662 - f.print(x.Lbrack, token.LBRACK, indent) 662 + f.print(x.Lbrack, token.LBRACK, noblank, indent) 663 663 f.walkListElems(x.Elts) 664 664 f.print(trailcomma, noblank) 665 665 f.visitComments(f.current.pos)
+18 -2
cue/format/testdata/expressions.golden
··· 144 144 e: [...int] 145 145 e: [...int] 146 146 e: [...int | float] 147 - e: [ for x in someObject if x > 9 { 147 + e: [for x in someObject if x > 9 { 148 148 x 149 149 }] 150 - e: [ for x in someObject if x > 9 {x}] 150 + e: [for x in someObject if x > 9 {x}] 151 151 e: [ 152 152 for x in someObject 153 153 if x > 9 {x}] ··· 253 253 254 254 2, 255 255 ]) 256 + 257 + m: [1, 2, 3] 258 + m: [1, 2, 3] 259 + m: [1, 2, 3] 260 + m: [1, 2, 3] 261 + m: [1, 2, 3] 262 + m: [1, 2, 3] 263 + m: [1, 2, 3] 264 + m: [1, 2, 3] 265 + m: [1, 2, 3] 266 + m: [if true {1}, 2, 3] 267 + n: [1] 268 + o: [{}] 269 + o: [{}] 270 + o: [{}] 271 + o: [{}] 256 272 }
+18 -2
cue/format/testdata/expressions.input
··· 142 142 e: [...int] 143 143 e: [...int,] 144 144 e: [...int | float] 145 - e: [ for x in someObject if x > 9 { 145 + e: [for x in someObject if x > 9 { 146 146 x 147 147 }] 148 - e: [ for x in someObject if x > 9 {x}] 148 + e: [for x in someObject if x > 9 {x}] 149 149 e: [ 150 150 for x in someObject 151 151 if x > 9 {x}] ··· 250 250 251 251 2, 252 252 ]) 253 + 254 + m: [1, 2, 3] 255 + m: [1, 2, 3,] 256 + m: [ 1, 2, 3, ] 257 + m: [ 1, 2, 3,] 258 + m: [ 1, 2, 3,] 259 + m: [ 1, 2, 3] 260 + m: [ 1, 2, 3,] 261 + m: [ 1, 2, 3, ] 262 + m: [ 1, 2, 3 ] 263 + m: [ if true { 1 }, 2, 3] 264 + n: [ 1] 265 + o: [{}] 266 + o: [ {}] 267 + o: [{} ] 268 + o: [ {} ] 253 269 }
+2 -2
cue/parser/parser_test.go
··· 300 300 "list types", 301 301 `{ 302 302 a: 4*[int] 303 - b: <=5*[ {a: 5} ] 303 + b: <=5*[{a: 5}] 304 304 c1: [...int] 305 305 c2: [...] 306 306 c3: [1, 2, ...int,] ··· 310 310 "list comprehensions", 311 311 `{ 312 312 y: [1,2,3] 313 - b: [ for x in y if x == 1 { x } ], 313 + b: [for x in y if x == 1 { x }], 314 314 }`, 315 315 `{y: [1, 2, 3], b: [for x in y if x==1 {x}]}`, 316 316 }, {
+1 -1
cue/testdata/benchmarks/issue2176.txtar
··· 37 37 } 38 38 } 39 39 } 40 - [ for i, _ in unique_combinations {i}][0] 40 + [for i, _ in unique_combinations {i}][0] 41 41 } 42 42 } 43 43 }
+1 -1
cue/testdata/builtins/incomplete.txtar
··· 14 14 15 15 // This evaluates to a list with an incomplete element. 16 16 Top: [ 17 - [ for _, F in _Sub {F}], 17 + [for _, F in _Sub {F}], 18 18 ] 19 19 20 20 _Sub: a.b
+3 -3
cue/testdata/compile/labels.txtar
··· 22 22 ok10: [{foo: "bar"}]: string // disallowed in evaluator 23 23 ok11: [list.FlattenN([string], 1)]: string // disallowed in evaluator 24 24 25 - bad1: [ for x in [1, 2, 3] {x}]: string 25 + bad1: [for x in [1, 2, 3] {x}]: string 26 26 27 27 saneReferencesInComprehensions: { 28 28 for _ in [1] { ··· 31 31 } 32 32 -- out/compile -- 33 33 bad1: comprehension values not allowed in this position: 34 - ./in.cue:24:9 34 + ./in.cue:24:8 35 35 --- in.cue 36 36 { 37 37 dis1: ("dev"|"prd") ··· 91 91 } 92 92 -- out/eval -- 93 93 bad1: comprehension values not allowed in this position: 94 - ./in.cue:24:9 94 + ./in.cue:24:8
+3 -3
cue/testdata/comprehensions/015_list_comprehension.txtar
··· 3 3 #name: list comprehension 4 4 #evalFull 5 5 -- in.cue -- 6 - a: [ for k, v in b if k < "d" if v > b.a {k}] 6 + a: [for k, v in b if k < "d" if v > b.a {k}] 7 7 b: { 8 8 a: 1 9 9 b: 2 10 10 c: 3 11 11 d: 4 12 12 } 13 - c: [ for _, x in b for _, y in b if x < y {x}] 14 - d: [ for x, _ in a {x}] 13 + c: [for _, x in b for _, y in b if x < y {x}] 14 + d: [for x, _ in a {x}] 15 15 -- out/def -- 16 16 a: ["b", "c"] 17 17 b: {
+6 -6
cue/testdata/comprehensions/checkdefined.txtar
··· 17 17 oko1: { if xo.undefined != _|_ {a: 1} } 18 18 19 19 okc2: { 20 - if ({} & {s: [ for y in xc.undefined {}]}) != _|_ {a: 1} 20 + if ({} & {s: [for y in xc.undefined {}]}) != _|_ {a: 1} 21 21 } 22 22 23 23 oko2: { 24 - if ({} & {s: [ for y in xo.undefined {}]}) != _|_ {a: 1} 24 + if ({} & {s: [for y in xo.undefined {}]}) != _|_ {a: 1} 25 25 } 26 26 27 27 okc3: { 28 - if ({s: [ for y in xc.undefined {}]}) != _|_ {a: 1} 28 + if ({s: [for y in xc.undefined {}]}) != _|_ {a: 1} 29 29 } 30 30 31 31 oko3: { 32 - if ({s: [ for y in xo.undefined {}]}) != _|_ {a: 1} 32 + if ({s: [for y in xo.undefined {}]}) != _|_ {a: 1} 33 33 } 34 34 35 35 issue1969: okc: { 36 36 let X = xc.undefined 37 - let Y = {} & {s: [ for y in list.Range(0, X, 1) {}]} 37 + let Y = {} & {s: [for y in list.Range(0, X, 1) {}]} 38 38 39 39 if Y != _|_ {Y} 40 40 } 41 41 42 42 issue1969: oko: { 43 43 let X = xo.undefined 44 - let Y = {} & {s: [ for y in list.Range(0, X, 1) {}]} 44 + let Y = {} & {s: [for y in list.Range(0, X, 1) {}]} 45 45 46 46 if Y != _|_ {Y} 47 47 }
+2 -2
cue/testdata/comprehensions/incomplete.txtar
··· 3 3 src: {} 4 4 top: _ 5 5 a: [ if cond {}] 6 - b: [ for x in src.foo {}] 6 + b: [for x in src.foo {}] 7 7 c: {for x in top {}} 8 8 -- out/eval/stats -- 9 9 Leaks: 0 ··· 27 27 } 28 28 b: (_|_){ 29 29 // [incomplete] b: undefined field: foo: 30 - // ./in.cue:5:19 30 + // ./in.cue:5:18 31 31 } 32 32 c: (_|_){ 33 33 // [incomplete] c: cannot range over top (incomplete type _):
+1 -1
cue/testdata/comprehensions/lists.txtar
··· 1 1 -- in.cue -- 2 2 a: [{a: 1}, {b: 2 & 3}] 3 3 4 - b: [ for x in a {x}] 4 + b: [for x in a {x}] 5 5 -- out/eval/stats -- 6 6 Leaks: 0 7 7 Freed: 7
+3 -3
cue/testdata/cycle/chain.txtar
··· 100 100 out: { 101 101 if (#in & #basic) != _|_ {1} 102 102 if (#in & #basic) == _|_ { 103 - list.Max([ for k, v in #in {(#next & {#in: v}).out}]) + 1 103 + list.Max([for k, v in #in {(#next & {#in: v}).out}]) + 1 104 104 } 105 105 } 106 106 } ··· 139 139 out: { 140 140 if (#in & #basic) != _|_ {1} 141 141 if (#in & #basic) == _|_ { 142 - list.Max([ for k, v in #in {(#next & {#in: v}).out}]) + 1 142 + list.Max([for k, v in #in {(#next & {#in: v}).out}]) + 1 143 143 } 144 144 } 145 145 } ··· 188 188 // if we are not a basic type, then we are 1 + the max of children 189 189 if (#in & #basic) == _|_ { 190 190 // this is our "recursion" for each child 191 - let depths = [ for k, v in #in {(#next & {#in: v}).out}] 191 + let depths = [for k, v in #in {(#next & {#in: v}).out}] 192 192 list.Max(depths) + 1 193 193 } 194 194 }
+13 -13
cue/testdata/cycle/comprehension.txtar
··· 4 4 A: { 5 5 a: { 6 6 parent: "" 7 - children: [ for k, v in A if v.parent == k {k}] 7 + children: [for k, v in A if v.parent == k {k}] 8 8 } 9 9 b: { 10 10 parent: "a" 11 - children: [ for k, v in A if v.parent == k {k}] 11 + children: [for k, v in A if v.parent == k {k}] 12 12 } 13 13 } 14 14 ··· 17 17 B: { 18 18 a: { 19 19 parent: "" 20 - children: [ for k, v in B for _, w in v.children {k}] 20 + children: [for k, v in B for _, w in v.children {k}] 21 21 } 22 22 } 23 23 ··· 131 131 retry: #Output 132 132 } 133 133 134 - #Output: or([ for name, config in #AllOutputs { 134 + #Output: or([for name, config in #AllOutputs { 135 135 (name): config 136 136 }]) 137 137 } 138 138 139 139 selfReferential: acrossOr: t1: p2: { 140 - #Output: or([ for name, config in #AllOutputs { 140 + #Output: or([for name, config in #AllOutputs { 141 141 (name): config 142 142 }]) 143 143 ··· 151 151 } 152 152 153 153 selfReferential: acrossOr: t1: p3: { 154 - #Output: or([ for name, config in #AllOutputs { 154 + #Output: or([for name, config in #AllOutputs { 155 155 (name): config 156 156 }]) 157 157 ··· 165 165 } 166 166 167 167 selfReferential: acrossOr: t2: p1: { 168 - d: or([ for x, y in #A { y } ]) 168 + d: or([for x, y in #A { y }]) 169 169 o: d & { b: 2 } 170 170 #A: { 171 171 d1: int ··· 176 176 177 177 selfReferential: acrossOr: t2: p2: { 178 178 o: d & { b: 2 } 179 - d: or([ for x, y in #A { y } ]) 179 + d: or([for x, y in #A { y }]) 180 180 #A: { 181 181 d1: int 182 182 d2: string ··· 191 191 d2: string 192 192 d3: b: d 193 193 } 194 - d: or([ for x, y in #A { y } ]) 194 + d: or([for x, y in #A { y }]) 195 195 } 196 196 197 197 issue1881: p1: { ··· 203 203 retry: output: #Output 204 204 } 205 205 206 - #Output: or([ for name, config in #AllOutputs { 206 + #Output: or([for name, config in #AllOutputs { 207 207 (name): config 208 208 }]) 209 209 } ··· 214 214 resource: string 215 215 retry: output: #Output 216 216 } 217 - 217 + 218 218 o: #Output & { retry: output: reject: "ok" } 219 219 220 - #Output: or([ for name, config in #AllOutputs { 220 + #Output: or([for name, config in #AllOutputs { 221 221 (name): config 222 222 }]) 223 223 } ··· 229 229 retry: output: #Output 230 230 } 231 231 232 - #Output: or([ for name, config in #AllOutputs { 232 + #Output: or([for name, config in #AllOutputs { 233 233 (name): config 234 234 }]) 235 235
+1 -1
cue/testdata/cycle/evaluate.txtar
··· 58 58 59 59 forCycle: { 60 60 #A: a: #B // TODO(errors): Correct error position. 61 - #B: or([ for x in #A { b: x } ]) 61 + #B: or([for x in #A { b: x }]) 62 62 } 63 63 64 64 letCycleWithAnd: {
+6 -6
cue/testdata/cycle/issue1960.txtar
··· 1 1 // Issue-specific tests. Essence tested in evaluate.txtar (LetCycle*). 2 2 -- issue1960.cue -- 3 3 t1: { 4 - z: blah: s: [ for z in z {}] 4 + z: blah: s: [for z in z {}] 5 5 z: hello: { 6 6 for x in p {} 7 7 let q = z.blah ··· 11 11 } 12 12 13 13 t2: { 14 - z: blah: s: [ for z in z {}] 14 + z: blah: s: [for z in z {}] 15 15 z: hello: { 16 16 for x in p {} 17 17 let q = z.blah ··· 34 34 } 35 35 } 36 36 } 37 - 37 + 38 38 #i: { 39 39 #z 40 40 t: "i" 41 41 r: e: {} 42 42 } 43 - 43 + 44 44 #c: { 45 45 #z 46 46 t: "c" 47 47 n: string 48 48 } 49 - 49 + 50 50 z: [N= =~"^b"]: #i & { 51 51 s: [ 52 52 for n, z in z ··· 54 54 if z.n == N {n}, 55 55 ] 56 56 } 57 - 57 + 58 58 z: [N= =~"^h"]: #c & { 59 59 n: string 60 60 // Causes a structural cycle on its own, but not when referenced below.
+2 -2
cue/testdata/cycle/structural.txtar
··· 189 189 } 190 190 191 191 // Issue #587 192 - b13: root: a: [ for x in root {x}] 192 + b13: root: a: [for x in root {x}] 193 193 194 194 // Issue #587 195 195 // TODO: this should probably be okay if we allow shallow evaluation of ··· 202 202 "\(x)": {} 203 203 } 204 204 205 - b: [ for x in root {x}] 205 + b: [for x in root {x}] 206 206 } 207 207 } 208 208
+2 -2
cue/testdata/definitions/issue317.txtar
··· 25 25 #Deployment: { 26 26 #Containers: [Name=string]: #Container 27 27 28 - containers: [ for c in #Containers {c}] // Problem is here. 28 + containers: [for c in #Containers {c}] // Problem is here. 29 29 } 30 30 Something: { 31 31 #Deployment ··· 150 150 #Deployment: { 151 151 #Containers: [Name=string]: #Container 152 152 153 - containers: [ for c in #Containers {c}] // Problem is here. 153 + containers: [for c in #Containers {c}] // Problem is here. 154 154 } 155 155 Something: { 156 156 #Deployment
+1 -1
cue/testdata/definitions/issue491.txtar
··· 29 29 30 30 z: #PrestepNewUser & { 31 31 Args: { 32 - Repos: [ { 32 + Repos: [{ 33 33 Var: "REPO1" 34 34 }] 35 35 }
+7 -7
cue/testdata/disjunctions/elimination.txtar
··· 382 382 #FormFoo: fooID: string 383 383 #FormBar: barID: string 384 384 #Form: { #FormFoo | #FormBar } 385 - 385 + 386 386 data: {fooID: "123"} 387 387 out1: #Form & data 388 388 out2: #Form & out1 ··· 391 391 data: forms: [{ 392 392 fooID: "00-0000001" 393 393 }] 394 - 394 + 395 395 form1040: (#compute & {in: data}).out 396 - 396 + 397 397 #K1: { 398 398 #_base: common: 3 399 399 #FormFoo: { ··· 408 408 #FormFoo | #FormBar 409 409 } 410 410 } 411 - 411 + 412 412 #Input: { 413 413 forms: [...#K1.#Form] 414 414 } 415 - 415 + 416 416 #summarizeReturn: { 417 417 in: #Input 418 - out: [ for k in in.forms { k.common } ] 418 + out: [for k in in.forms { k.common }] 419 419 } 420 - 420 + 421 421 #compute: { 422 422 in: #Input 423 423 out: (#summarizeReturn & {"in": in}).out
+2 -2
cue/testdata/eval/conjuncts.txtar
··· 34 34 let _param = "foo" 35 35 ({ 36 36 param: _param & [{}] 37 - gen: [ for p in param {p}] 37 + gen: [for p in param {p}] 38 38 }).gen 39 39 } 40 40 ··· 42 42 _in1: ["foo"] 43 43 { 44 44 in2: _in1 45 - out: [ for x in in2 {x}] 45 + out: [for x in in2 {x}] 46 46 }.out 47 47 } 48 48
+1 -1
cue/testdata/eval/discontinuous.txtar
··· 2 2 before evaluating a parent has completed. 3 3 4 4 -- in.cue -- 5 - a: [ for c in foo.bar.baz { 5 + a: [for c in foo.bar.baz { 6 6 c 7 7 }] 8 8
+7 -7
cue/testdata/eval/issue2146.txtar
··· 8 8 #A: { 9 9 x?: int 10 10 y?: int 11 - 11 + 12 12 let list = [x, y] 13 - all: [ for v in list if v != _|_ {v}] 14 - 13 + all: [for v in list if v != _|_ {v}] 14 + 15 15 *{ 16 16 x?: _|_ 17 17 y: 1 18 18 } | _ 19 19 } 20 - 20 + 21 21 a: #A & { x: 3 } 22 22 b: #A & a 23 23 } ··· 25 25 #A: { 26 26 x?: int 27 27 y?: int 28 - 28 + 29 29 let list = [x, y] 30 - all: [ for v in list if v != _|_ {v}] 30 + all: [for v in list if v != _|_ {v}] 31 31 32 32 _ | *{ 33 33 x?: _|_ 34 34 y: 1 35 35 } 36 36 } 37 - 37 + 38 38 a: #A & { x: 3, y: 2 } 39 39 b: #A & a 40 40 }
+1 -1
cue/testdata/eval/let.txtar
··· 28 28 volumes: L3 29 29 30 30 let L3 = { 31 - for v2 in [ for v1 in L2 {} ] {} 31 + for v2 in [for v1 in L2 {}] {} 32 32 } 33 33 34 34 let L2 = L1
+1 -1
cue/testdata/eval/lists.txtar
··· 6 6 b: a[3] 7 7 d: 5 8 8 9 - c: [ for x in [[1, 2]][0] {x + d}] 9 + c: [for x in [[1, 2]][0] {x + d}] 10 10 -- out/eval/stats -- 11 11 Leaks: 4 12 12 Freed: 11
+1 -1
cue/testdata/export/018.txtar
··· 2 2 # 3 3 raw: true 4 4 -- in.cue -- 5 - {a: [1, 2], b: [ for k, v in a {v}]} 5 + {a: [1, 2], b: [for k, v in a {v}]} 6 6 -- out/def -- 7 7 a: [1, 2] 8 8 b: [1, 2]
+2 -2
cue/testdata/fulleval/012_disjunctions_of_lists.txtar
··· 5 5 -- in.cue -- 6 6 l: *[ int, int] | [ string, string] 7 7 8 - l1: [ "a", "b"] 9 - l2: l & [ "c", "d"] 8 + l1: ["a", "b"] 9 + l2: l & ["c", "d"] 10 10 -- out/def -- 11 11 l: *[int, int] | [string, string] 12 12 l1: ["a", "b"]
+1 -1
cue/testdata/fulleval/016_struct_comprehension_with_template.txtar
··· 3 3 #name: struct comprehension with template 4 4 #evalFull 5 5 -- in.cue -- 6 - result: [ for _, v in service {v}] 6 + result: [for _, v in service {v}] 7 7 8 8 service: [Name=string]: { 9 9 name: *Name | string
+1 -1
cue/testdata/fulleval/020_complex_interaction_of_groundness.txtar
··· 3 3 #name: complex interaction of groundness 4 4 #evalFull 5 5 -- in.cue -- 6 - res: [ for x in a for y in x {y & {d: "b"}}] 6 + res: [for x in a for y in x {y & {d: "b"}}] 7 7 res: [ a.b.c & {d: "b"}] 8 8 9 9 a: b: [C=string]: {d: string, s: "a" + d}
+2 -2
cue/testdata/fulleval/032_or_builtin_should_not_fail_on_non-concrete_empty_list.txtar
··· 8 8 [jobID=string]: { 9 9 } 10 10 } 11 - #JobID: or([ for k, _ in jobs {k}]) 11 + #JobID: or([for k, _ in jobs {k}]) 12 12 } 13 13 14 14 foo: #Workflow & { ··· 20 20 jobs: { 21 21 [jobID=string]: {} 22 22 } 23 - #JobID: or([ for k, _ in jobs { k } ]) 23 + #JobID: or([for k, _ in jobs { k }]) 24 24 } 25 25 foo: #Workflow & { 26 26 jobs: {
+4 -4
cue/testdata/fulleval/049_alias_reuse_in_nested_scope.txtar
··· 4 4 #evalFull 5 5 -- in.cue -- 6 6 #Foo: { 7 - let X = or([ for k, _ in {} {k}]) 7 + let X = or([for k, _ in {} {k}]) 8 8 connection: [X]: X 9 9 } 10 10 #A: { ··· 21 21 -- out/def -- 22 22 #Foo: { 23 23 connection: { 24 - [or([ for k, _ in { 24 + [or([for k, _ in { 25 25 ... 26 - } { k } ])]: or([ for k, _ in { 26 + } { k }])]: or([for k, _ in { 27 27 ... 28 - } { k } ]) 28 + } { k }]) 29 29 } 30 30 } 31 31 #A: {
+3 -3
cue/testdata/references/let.txtar
··· 15 15 16 16 a4list: [{4}] 17 17 let A4 = a4list 18 - a4: [ for x in A4 {v: 404}] 18 + a4: [for x in A4 {v: 404}] 19 19 20 20 a5list: [{5}] 21 21 let A5 = a5list 22 - a5: b: [ for x in A5 {v: 505}] 22 + a5: b: [for x in A5 {v: 505}] 23 23 24 24 a6list: [{6}] 25 25 let A6 = a6list 26 - a6: b: c: [ for x in A6 {v: 606}] 26 + a6: b: c: [for x in A6 {v: 606}] 27 27 28 28 a7list: [{7}] 29 29 let A7 = a7list
+2 -2
cue/testdata/resolve/017_disjunctions_of_lists.txtar
··· 5 5 -- in.cue -- 6 6 l: [ int, int] | [ string, string] 7 7 8 - l1: [ "a", "b"] 9 - l2: l & [ "c", "d"] 8 + l1: ["a", "b"] 9 + l2: l & ["c", "d"] 10 10 -- out/def -- 11 11 l: [int, int] | [string, string] 12 12 l1: ["a", "b"]
+1 -1
doc/ref/spec.md
··· 2625 2625 2626 2626 ``` 2627 2627 a: [1, 2, 3, 4] 2628 - b: [ for x in a if x > 1 { x+1 } ] // [3, 4, 5] 2628 + b: [for x in a if x > 1 { x+1 }] // [3, 4, 5] 2629 2629 2630 2630 c: { 2631 2631 for x in a
+1 -1
doc/tutorial/basics/6_expressions/40_listcomp.txtar
··· 11 11 The example shows the use of `for` loops and `if` guards. 12 12 13 13 -- listcomp.cue -- 14 - [ for x in #items if x rem 2 == 0 { x*x } ] 14 + [for x in #items if x rem 2 == 0 { x*x }] 15 15 16 16 #items: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] 17 17
+1 -1
doc/tutorial/basics/6_expressions/50_fieldcomp.txtar
··· 14 14 -- fieldcomp.cue -- 15 15 import "strings" 16 16 17 - #a: [ "Barcelona", "Shanghai", "Munich" ] 17 + #a: ["Barcelona", "Shanghai", "Munich"] 18 18 19 19 for k, v in #a { 20 20 "\( strings.ToLower(v) )": {
+3 -3
doc/tutorial/basics/6_expressions/80_coalesce.txtar
··· 8 8 -- text.md -- 9 9 <!-- jba: the terms here are confusing. "Null coalescing" is actually not 10 10 that, but then there is something called "actual null coalescing." 11 - 11 + 12 12 Just say that because _|_ | X evaluates to X, you can use disjunction 13 13 to represent fallback values. 14 - 14 + 15 15 And then you can use that to effectively type-check with a default value. 16 16 --> 17 17 ··· 28 28 the result is not of the desired type. 29 29 30 30 -- coalesce.cue -- 31 - list: [ "Cat", "Mouse", "Dog" ] 31 + list: ["Cat", "Mouse", "Dog"] 32 32 33 33 a: *list[0] | "None" 34 34 b: *list[5] | "None"
+3 -3
doc/tutorial/kubernetes/README.md
··· 886 886 $ cat <<EOF > kube_tool.cue 887 887 package kube 888 888 889 - objects: [ for v in objectSets for x in v {x}] 889 + objects: [for v in objectSets for x in v {x}] 890 890 891 891 objectSets: [ 892 892 service, ··· 1202 1202 Arguments can be specified as a map. 1203 1203 ``` 1204 1204 arg: [string]: string 1205 - args: [ for k, v in arg { "-\(k)=\(v)" } ] | [...string] 1205 + args: [for k, v in arg { "-\(k)=\(v)" }] | [...string] 1206 1206 ``` 1207 1207 1208 1208 If order matters, users could explicitly specify the list as well. ··· 1307 1307 metadata: labels: x.label 1308 1308 spec: selector: x.label 1309 1309 1310 - spec: ports: [ for p in x.port { p } ] 1310 + spec: ports: [for p in x.port { p }] 1311 1311 } 1312 1312 } 1313 1313 }
+1 -1
doc/tutorial/kubernetes/manual/services/cloud.cue
··· 26 26 port: [string]: int 27 27 28 28 arg: [string]: string 29 - args: *[ for k, v in arg {"-\(k)=\(v)"}] | [...string] 29 + args: *[for k, v in arg {"-\(k)=\(v)"}] | [...string] 30 30 31 31 // Environment variables 32 32 env: [string]: string
+3 -3
doc/tutorial/kubernetes/manual/services/k8s.cue
··· 10 10 metadata: labels: x.label 11 11 spec: selector: x.label 12 12 13 - spec: ports: [ for p in x.port {p}] // convert struct to list 13 + spec: ports: [for p in x.port {p}] // convert struct to list 14 14 } 15 15 } 16 16 // Note that we cannot write ··· 84 84 image: X.image 85 85 args: X.args 86 86 if len(X.envSpec) > 0 { 87 - env: [ for k, v in X.envSpec {v, name: k}] 87 + env: [for k, v in X.envSpec {v, name: k}] 88 88 } 89 89 90 - ports: [ for k, p in X.expose.port & X.port { 90 + ports: [for k, p in X.expose.port & X.port { 91 91 name: k 92 92 containerPort: p 93 93 }]
+1 -1
doc/tutorial/kubernetes/manual/services/kube_tool.cue
··· 1 1 package kube 2 2 3 - objects: [ for v in objectSets for x in v { x } ] 3 + objects: [for v in objectSets for x in v { x }] 4 4 5 5 objectSets: [ 6 6 kubernetes.services,
+1 -1
doc/tutorial/kubernetes/quick/services/kube_tool.cue
··· 1 1 package kube 2 2 3 - objects: [ for v in objectSets for x in v {x}] 3 + objects: [for v in objectSets for x in v {x}] 4 4 5 5 objectSets: [ 6 6 service,
+2 -2
encoding/protobuf/textproto/testdata/decoder/list.txtar
··· 16 16 float1: [...number] 17 17 -- input.textproto -- 18 18 empty1: [] 19 - empty2: [ # foo 19 + empty2: [# foo 20 20 ] 21 21 22 22 int1: [1, 2] ··· 34 34 float1: [ 1e+2 1. 0] 35 35 -- out/decode -- 36 36 empty1: [] 37 - empty2: [ // foo 37 + empty2: [// foo 38 38 ] 39 39 int1: [1, 2] 40 40 int2: [1, 2] // omitting commas okay
+1 -1
internal/ci/base/codereview.cue
··· 21 21 // the key: value 22 22 toCodeReviewCfg: { 23 23 #input: #codeReview 24 - let parts = [ for k, v in #input {k + ": " + v}] 24 + let parts = [for k, v in #input {k + ": " + v}] 25 25 26 26 // Per https://pkg.go.dev/golang.org/x/review/git-codereview#hdr-Configuration 27 27 strings.Join(parts, "\n")
+1 -1
internal/ci/base/github.cue
··· 278 278 // but array literals are not yet supported in expressions. 279 279 isProtectedBranch: { 280 280 #trailers: [...string] 281 - "((" + strings.Join([ for branch in protectedBranchPatterns { 281 + "((" + strings.Join([for branch in protectedBranchPatterns { 282 282 (_matchPattern & {variable: "github.ref", pattern: "refs/heads/\(branch)"}).expr 283 283 }], " || ") + ") && (! \(containsDispatchTrailer)))" 284 284 }
+1 -1
internal/ci/ci_tool.cue
··· 55 55 for _workflowName, _workflow in github.workflows { 56 56 let _filename = _workflowName + repo.workflowFileExtension 57 57 "generate \(_filename)": file.Create & { 58 - $after: [ for v in remove {v}] 58 + $after: [for v in remove {v}] 59 59 filename: path.Join([_dir, _filename], _goos) 60 60 let donotedit = repo.doNotEditMessage & {#generatedBy: "internal/ci/ci_tool.cue", _} 61 61 contents: "# \(donotedit)\n\n\(yaml.Marshal(_workflow))"
+1 -1
internal/core/dep/testdata/dynamic.txtar
··· 19 19 } 20 20 21 21 a: { 22 - b: [ for x in middle {x}] 22 + b: [for x in middle {x}] 23 23 c: {} 24 24 } 25 25 -- out/dependencies/field --
+1 -1
internal/core/dep/testdata/listcomprehension.txtar
··· 1 1 -- in.cue -- 2 - a: b: [ for x in c if x.a > 0 {x.a + d}] 2 + a: b: [for x in c if x.a > 0 {x.a + d}] 3 3 4 4 c: [{a: 1}, {a: 3}] 5 5 d: 2
+2 -2
internal/core/export/testdata/main/let.txtar
··· 17 17 let Y = x 18 18 y: Y 19 19 -- issue593.cue -- 20 - cfgs: [ for crd in ["one", "two"] { 20 + cfgs: [for crd in ["one", "two"] { 21 21 metadata: { 22 22 name: crd 23 23 } ··· 137 137 let Y = x 138 138 let Y_1 = x 139 139 { 140 - cfgs: [ for crd in ["one", "two"] { 140 + cfgs: [for crd in ["one", "two"] { 141 141 metadata: { 142 142 name: crd 143 143 }
+1 -1
internal/encoding/json/encode_test.go
··· 154 154 a: 1 155 155 b: 3 156 156 } 157 - c: [1, [ for x in m { x } ]] 157 + c: [1, [for x in m { x }]] 158 158 `, 159 159 out: "json: unsupported node for x in m {x} (*ast.Comprehension)", 160 160 }, {
+1 -1
internal/encoding/yaml/encode_test.go
··· 170 170 a: 1 171 171 b: 3 172 172 } 173 - c: [1, [ for x in m {x}]] 173 + c: [1, [for x in m {x}]] 174 174 `, 175 175 out: "yaml: unsupported node for x in m {x} (*ast.Comprehension)", 176 176 }, {
+1 -1
pkg/list/list.go
··· 149 149 // 150 150 // Concat([a, b, c]) is equivalent to 151 151 // 152 - // [ for x in a {x}, for x in b {x}, for x in c {x} ] 152 + // [for x in a {x}, for x in b {x}, for x in c {x}] 153 153 func Concat(a []cue.Value) ([]cue.Value, error) { 154 154 var res []cue.Value 155 155 for _, e := range a {
+1 -1
pkg/tool/exec/exec_test.go
··· 43 43 }, { 44 44 val: ` 45 45 cmd: "echo" 46 - env: [ "WHO=World", "WHAT=Hello", "WHEN=Now!" ] 46 + env: ["WHO=World", "WHAT=Hello", "WHEN=Now!"] 47 47 `, 48 48 env: []string{"WHO=World", "WHAT=Hello", "WHEN=Now!"}, 49 49 }}
+1 -1
tools/flow/testdata/dep.txtar
··· 52 52 } 53 53 54 54 incompleteList: { 55 - x: [ for x in [1] {incompleteComprehensionSource.x}] 55 + x: [for x in [1] {incompleteComprehensionSource.x}] 56 56 } 57 57 58 58 incompleteGeneratedStruct: {
+1 -1
tools/flow/testdata/dynamic.txtar
··· 16 16 // Run this after all generated tasks (so far) 17 17 b: { 18 18 $id: "list" 19 - $after: [ for x in middle {x}] 19 + $after: [for x in middle {x}] 20 20 out: [...int] 21 21 } 22 22 after: {
+1 -1
tools/flow/testdata/issue2416b.txtar
··· 22 22 } 23 23 24 24 root: print: cli.Print & { 25 - text: strings.Join([ for key, val in outputs { "key=\(key) val=\(val)" } ], "\n") 25 + text: strings.Join([for key, val in outputs { "key=\(key) val=\(val)" }], "\n") 26 26 } 27 27 -- out/run/errors -- 28 28 -- out/run/t0 --
+2 -2
tools/trim/testdata/defaults.txtar
··· 59 59 // was first used to select the default. 60 60 dontEraseDefaultSelection: { 61 61 rule: _#Rule & { 62 - verbs: [ "c"] 62 + verbs: ["c"] 63 63 } 64 64 _#Rule: { 65 65 verbs: *["a", "b"] | ["c"] ··· 127 127 // was first used to select the default. 128 128 dontEraseDefaultSelection: { 129 129 rule: _#Rule & { 130 - verbs: [ "c"] 130 + verbs: ["c"] 131 131 } 132 132 _#Rule: { 133 133 verbs: *["a", "b"] | ["c"]