From d70007c116281516ed051982a9897013119df417 Mon Sep 17 00:00:00 2001 From: Thomas Way Date: Thu, 26 Oct 2023 22:48:53 +0100 Subject: [PATCH] cmd/format: be consistent with whitespace in lists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1171302 Reviewed-by: Daniel Martí TryBot-Result: CUEcueckoo --- cmd/cue/cmd/eval.go | 2 +- cmd/cue/cmd/root.go | 2 +- cmd/cue/cmd/testdata/script/cmd_cycle.txtar | 2 +- cmd/cue/cmd/testdata/script/cmd_func.txtar | 2 +- .../cmd/testdata/script/cmd_issue2060.txtar | 4 +-- .../testdata/script/eval_mixedfiletypes.txtar | 2 +- cmd/cue/cmd/testdata/script/help.txtar | 2 +- cmd/cue/cmd/testdata/script/issue473.txtar | 4 +-- cmd/cue/cmd/testdata/script/load_pkg.txtar | 2 +- .../testdata/script/merge_interaction.txtar | 2 +- cue/format/node.go | 2 +- cue/format/testdata/expressions.golden | 20 ++++++++++++-- cue/format/testdata/expressions.input | 20 ++++++++++++-- cue/parser/parser_test.go | 4 +-- cue/testdata/benchmarks/issue2176.txtar | 2 +- cue/testdata/builtins/incomplete.txtar | 2 +- cue/testdata/compile/labels.txtar | 6 ++--- .../015_list_comprehension.txtar | 6 ++--- .../comprehensions/checkdefined.txtar | 12 ++++----- cue/testdata/comprehensions/incomplete.txtar | 4 +-- cue/testdata/comprehensions/lists.txtar | 2 +- cue/testdata/cycle/chain.txtar | 6 ++--- cue/testdata/cycle/comprehension.txtar | 26 +++++++++---------- cue/testdata/cycle/evaluate.txtar | 2 +- cue/testdata/cycle/issue1960.txtar | 12 ++++----- cue/testdata/cycle/structural.txtar | 4 +-- cue/testdata/definitions/issue317.txtar | 4 +-- cue/testdata/definitions/issue491.txtar | 2 +- cue/testdata/disjunctions/elimination.txtar | 14 +++++----- cue/testdata/eval/conjuncts.txtar | 4 +-- cue/testdata/eval/discontinuous.txtar | 2 +- cue/testdata/eval/issue2146.txtar | 14 +++++----- cue/testdata/eval/let.txtar | 2 +- cue/testdata/eval/lists.txtar | 2 +- cue/testdata/export/018.txtar | 2 +- .../fulleval/012_disjunctions_of_lists.txtar | 4 +-- ...6_struct_comprehension_with_template.txtar | 2 +- ...20_complex_interaction_of_groundness.txtar | 2 +- ..._not_fail_on_non-concrete_empty_list.txtar | 4 +-- .../049_alias_reuse_in_nested_scope.txtar | 8 +++--- cue/testdata/references/let.txtar | 6 ++--- .../resolve/017_disjunctions_of_lists.txtar | 4 +-- doc/ref/spec.md | 2 +- .../basics/6_expressions/40_listcomp.txtar | 2 +- .../basics/6_expressions/50_fieldcomp.txtar | 2 +- .../basics/6_expressions/80_coalesce.txtar | 6 ++--- doc/tutorial/kubernetes/README.md | 6 ++--- .../kubernetes/manual/services/cloud.cue | 2 +- .../kubernetes/manual/services/k8s.cue | 6 ++--- .../kubernetes/manual/services/kube_tool.cue | 2 +- .../kubernetes/quick/services/kube_tool.cue | 2 +- .../textproto/testdata/decoder/list.txtar | 4 +-- internal/ci/base/codereview.cue | 2 +- internal/ci/base/github.cue | 2 +- internal/ci/ci_tool.cue | 2 +- internal/core/dep/testdata/dynamic.txtar | 2 +- .../core/dep/testdata/listcomprehension.txtar | 2 +- internal/core/export/testdata/main/let.txtar | 4 +-- internal/encoding/json/encode_test.go | 2 +- internal/encoding/yaml/encode_test.go | 2 +- pkg/list/list.go | 2 +- pkg/tool/exec/exec_test.go | 2 +- tools/flow/testdata/dep.txtar | 2 +- tools/flow/testdata/dynamic.txtar | 2 +- tools/flow/testdata/issue2416b.txtar | 2 +- tools/trim/testdata/defaults.txtar | 4 +-- 66 files changed, 164 insertions(+), 132 deletions(-) diff --git a/cmd/cue/cmd/eval.go b/cmd/cue/cmd/eval.go index 16eee6abdc0..f1a46777835 100644 --- a/cmd/cue/cmd/eval.go +++ b/cmd/cue/cmd/eval.go @@ -42,7 +42,7 @@ configuration file, instead of the entire configuration file itself. Examples: $ cat < foo.cue - a: [ "a", "b", "c" ] + a: ["a", "b", "c"] EOF $ cue eval foo.cue -e a[0] -e a[2] diff --git a/cmd/cue/cmd/root.go b/cmd/cue/cmd/root.go index 4d62084a3f6..2aa62e1c6ae 100644 --- a/cmd/cue/cmd/root.go +++ b/cmd/cue/cmd/root.go @@ -140,7 +140,7 @@ Commands are defined in CUE as follows: command: deploy: { exec.Run cmd: "kubectl" - args: [ "-f", "deploy" ] + args: ["-f", "deploy"] in: json.Encode(userValue) // encode the emitted configuration. } diff --git a/cmd/cue/cmd/testdata/script/cmd_cycle.txtar b/cmd/cue/cmd/testdata/script/cmd_cycle.txtar index aef933b14e8..6f93af5bdb7 100644 --- a/cmd/cue/cmd/testdata/script/cmd_cycle.txtar +++ b/cmd/cue/cmd/testdata/script/cmd_cycle.txtar @@ -99,7 +99,7 @@ for _, input in inputs { } command: print: cli.Print & { - text: strings.Join([ for key, val in outputs { "key=\(key) val=\(val)" } ], "\n") + text: strings.Join([for key, val in outputs { "key=\(key) val=\(val)" }], "\n") } -- stdout2397.golden -- diff --git a/cmd/cue/cmd/testdata/script/cmd_func.txtar b/cmd/cue/cmd/testdata/script/cmd_func.txtar index e7e37308b14..7921b3c6738 100644 --- a/cmd/cue/cmd/testdata/script/cmd_func.txtar +++ b/cmd/cue/cmd/testdata/script/cmd_func.txtar @@ -8,7 +8,7 @@ import "encoding/json" x: y: 2 -objects: [ for v in [ json.Marshal(x) ] {v} ] +objects: [for v in [json.Marshal(x)] {v}] -- k_tool.cue -- package kube diff --git a/cmd/cue/cmd/testdata/script/cmd_issue2060.txtar b/cmd/cue/cmd/testdata/script/cmd_issue2060.txtar index 422a500f528..a3c5713cb61 100644 --- a/cmd/cue/cmd/testdata/script/cmd_issue2060.txtar +++ b/cmd/cue/cmd/testdata/script/cmd_issue2060.txtar @@ -118,9 +118,9 @@ buildSource: { Bindings: [ for _, strokeDef in strokeDefs { let bindingMap = strokeDef.Bindings["\(PlatformName)"] - let bindingIds = [ for k, v in bindingMap {name: k, idx: v}] + let bindingIds = [for k, v in bindingMap {name: k, idx: v}] let bindingIdsSorted = list.Sort(bindingIds, {x: {}, y: {}, less: x.idx < y.idx}) - let bindingKeys = [ for _, kv in bindingIdsSorted {kv.name}] + let bindingKeys = [for _, kv in bindingIdsSorted {kv.name}] let bindingText = strings.Join(bindingKeys, "+") "DefText": "\(strokeDef.DefText)" "BindText": bindingText diff --git a/cmd/cue/cmd/testdata/script/eval_mixedfiletypes.txtar b/cmd/cue/cmd/testdata/script/eval_mixedfiletypes.txtar index 3c297cea69c..5a0670daa99 100644 --- a/cmd/cue/cmd/testdata/script/eval_mixedfiletypes.txtar +++ b/cmd/cue/cmd/testdata/script/eval_mixedfiletypes.txtar @@ -40,7 +40,7 @@ checks: { } hasManager: { - ok: len([ for m in team if list.Contains(m, "EM") {m}]) >= 1 + ok: len([for m in team if list.Contains(m, "EM") {m}]) >= 1 } } -- y.cue -- diff --git a/cmd/cue/cmd/testdata/script/help.txtar b/cmd/cue/cmd/testdata/script/help.txtar index dae64e6e72f..100533a4bc3 100644 --- a/cmd/cue/cmd/testdata/script/help.txtar +++ b/cmd/cue/cmd/testdata/script/help.txtar @@ -19,7 +19,7 @@ Commands are defined in CUE as follows: command: deploy: { exec.Run cmd: "kubectl" - args: [ "-f", "deploy" ] + args: ["-f", "deploy"] in: json.Encode(userValue) // encode the emitted configuration. } diff --git a/cmd/cue/cmd/testdata/script/issue473.txtar b/cmd/cue/cmd/testdata/script/issue473.txtar index c9064e9e179..e6b287635ac 100644 --- a/cmd/cue/cmd/testdata/script/issue473.txtar +++ b/cmd/cue/cmd/testdata/script/issue473.txtar @@ -10,7 +10,7 @@ package x Steps: [string]: #Step - #TerminalName: or([ for k, _ in Terminals {k}]) + #TerminalName: or([for k, _ in Terminals {k}]) #Step: { Terminal: #TerminalName @@ -33,4 +33,4 @@ g: #Guide & { Cmd: "ls" } } -} \ No newline at end of file +} diff --git a/cmd/cue/cmd/testdata/script/load_pkg.txtar b/cmd/cue/cmd/testdata/script/load_pkg.txtar index 2935507c8b6..9c196e4f96a 100644 --- a/cmd/cue/cmd/testdata/script/load_pkg.txtar +++ b/cmd/cue/cmd/testdata/script/load_pkg.txtar @@ -61,7 +61,7 @@ foo: int bar: 3 -- sort/print.cue -- files: {} -flat: [ for k, _ in files {k} ] +flat: [for k, _ in files {k}] -- sort/root_1.cue -- files: root_1: 0 -- sort/root_2/child_1.cue -- diff --git a/cmd/cue/cmd/testdata/script/merge_interaction.txtar b/cmd/cue/cmd/testdata/script/merge_interaction.txtar index c140f4f0fb5..1a07a8afc8b 100644 --- a/cmd/cue/cmd/testdata/script/merge_interaction.txtar +++ b/cmd/cue/cmd/testdata/script/merge_interaction.txtar @@ -16,7 +16,7 @@ import ( "tool/cli" ) -objects: [ for x in map {x}] +objects: [for x in map {x}] command: dump: { cli.Print & { diff --git a/cue/format/node.go b/cue/format/node.go index de7a5250cb1..1aff2374913 100644 --- a/cue/format/node.go +++ b/cue/format/node.go @@ -659,7 +659,7 @@ func (f *formatter) exprRaw(expr ast.Expr, prec1, depth int) { f.print(ws, x.Rbrace, token.RBRACE) case *ast.ListLit: - f.print(x.Lbrack, token.LBRACK, indent) + f.print(x.Lbrack, token.LBRACK, noblank, indent) f.walkListElems(x.Elts) f.print(trailcomma, noblank) f.visitComments(f.current.pos) diff --git a/cue/format/testdata/expressions.golden b/cue/format/testdata/expressions.golden index faf8c72890f..36b25019b7c 100644 --- a/cue/format/testdata/expressions.golden +++ b/cue/format/testdata/expressions.golden @@ -144,10 +144,10 @@ import "list" e: [...int] e: [...int] e: [...int | float] - e: [ for x in someObject if x > 9 { + e: [for x in someObject if x > 9 { x }] - e: [ for x in someObject if x > 9 {x}] + e: [for x in someObject if x > 9 {x}] e: [ for x in someObject if x > 9 {x}] @@ -253,4 +253,20 @@ import "list" 2, ]) + + m: [1, 2, 3] + m: [1, 2, 3] + m: [1, 2, 3] + m: [1, 2, 3] + m: [1, 2, 3] + m: [1, 2, 3] + m: [1, 2, 3] + m: [1, 2, 3] + m: [1, 2, 3] + m: [if true {1}, 2, 3] + n: [1] + o: [{}] + o: [{}] + o: [{}] + o: [{}] } diff --git a/cue/format/testdata/expressions.input b/cue/format/testdata/expressions.input index 06de4e6bec2..c3356733163 100644 --- a/cue/format/testdata/expressions.input +++ b/cue/format/testdata/expressions.input @@ -142,10 +142,10 @@ import "list" e: [...int] e: [...int,] e: [...int | float] - e: [ for x in someObject if x > 9 { + e: [for x in someObject if x > 9 { x }] - e: [ for x in someObject if x > 9 {x}] + e: [for x in someObject if x > 9 {x}] e: [ for x in someObject if x > 9 {x}] @@ -250,4 +250,20 @@ import "list" 2, ]) + + m: [1, 2, 3] + m: [1, 2, 3,] + m: [ 1, 2, 3, ] + m: [ 1, 2, 3,] + m: [ 1, 2, 3,] + m: [ 1, 2, 3] + m: [ 1, 2, 3,] + m: [ 1, 2, 3, ] + m: [ 1, 2, 3 ] + m: [ if true { 1 }, 2, 3] + n: [ 1] + o: [{}] + o: [ {}] + o: [{} ] + o: [ {} ] } diff --git a/cue/parser/parser_test.go b/cue/parser/parser_test.go index 6af3c3507a7..477994d8431 100644 --- a/cue/parser/parser_test.go +++ b/cue/parser/parser_test.go @@ -300,7 +300,7 @@ func TestParse(t *testing.T) { "list types", `{ a: 4*[int] - b: <=5*[ {a: 5} ] + b: <=5*[{a: 5}] c1: [...int] c2: [...] c3: [1, 2, ...int,] @@ -310,7 +310,7 @@ func TestParse(t *testing.T) { "list comprehensions", `{ y: [1,2,3] - b: [ for x in y if x == 1 { x } ], + b: [for x in y if x == 1 { x }], }`, `{y: [1, 2, 3], b: [for x in y if x==1 {x}]}`, }, { diff --git a/cue/testdata/benchmarks/issue2176.txtar b/cue/testdata/benchmarks/issue2176.txtar index 4d9a098c13e..88faed0b1a1 100644 --- a/cue/testdata/benchmarks/issue2176.txtar +++ b/cue/testdata/benchmarks/issue2176.txtar @@ -37,7 +37,7 @@ import ( } } } - [ for i, _ in unique_combinations {i}][0] + [for i, _ in unique_combinations {i}][0] } } } diff --git a/cue/testdata/builtins/incomplete.txtar b/cue/testdata/builtins/incomplete.txtar index d1e481b9703..4d3e78c8ae1 100644 --- a/cue/testdata/builtins/incomplete.txtar +++ b/cue/testdata/builtins/incomplete.txtar @@ -14,7 +14,7 @@ list1: { // This evaluates to a list with an incomplete element. Top: [ - [ for _, F in _Sub {F}], + [for _, F in _Sub {F}], ] _Sub: a.b diff --git a/cue/testdata/compile/labels.txtar b/cue/testdata/compile/labels.txtar index 0c9c60f37c6..ce3b86bb61d 100644 --- a/cue/testdata/compile/labels.txtar +++ b/cue/testdata/compile/labels.txtar @@ -22,7 +22,7 @@ ok9: [name=dis2]: string ok10: [{foo: "bar"}]: string // disallowed in evaluator ok11: [list.FlattenN([string], 1)]: string // disallowed in evaluator -bad1: [ for x in [1, 2, 3] {x}]: string +bad1: [for x in [1, 2, 3] {x}]: string saneReferencesInComprehensions: { for _ in [1] { @@ -31,7 +31,7 @@ saneReferencesInComprehensions: { } -- out/compile -- bad1: comprehension values not allowed in this position: - ./in.cue:24:9 + ./in.cue:24:8 --- in.cue { dis1: ("dev"|"prd") @@ -91,4 +91,4 @@ bad1: comprehension values not allowed in this position: } -- out/eval -- bad1: comprehension values not allowed in this position: - ./in.cue:24:9 + ./in.cue:24:8 diff --git a/cue/testdata/comprehensions/015_list_comprehension.txtar b/cue/testdata/comprehensions/015_list_comprehension.txtar index 5a6763618b1..d48824c6188 100644 --- a/cue/testdata/comprehensions/015_list_comprehension.txtar +++ b/cue/testdata/comprehensions/015_list_comprehension.txtar @@ -3,15 +3,15 @@ #name: list comprehension #evalFull -- in.cue -- -a: [ for k, v in b if k < "d" if v > b.a {k}] +a: [for k, v in b if k < "d" if v > b.a {k}] b: { a: 1 b: 2 c: 3 d: 4 } -c: [ for _, x in b for _, y in b if x < y {x}] -d: [ for x, _ in a {x}] +c: [for _, x in b for _, y in b if x < y {x}] +d: [for x, _ in a {x}] -- out/def -- a: ["b", "c"] b: { diff --git a/cue/testdata/comprehensions/checkdefined.txtar b/cue/testdata/comprehensions/checkdefined.txtar index de1b466b5c5..390ad64d425 100644 --- a/cue/testdata/comprehensions/checkdefined.txtar +++ b/cue/testdata/comprehensions/checkdefined.txtar @@ -17,31 +17,31 @@ okc1: { if xc.undefined != _|_ {a: 1} } oko1: { if xo.undefined != _|_ {a: 1} } okc2: { - if ({} & {s: [ for y in xc.undefined {}]}) != _|_ {a: 1} + if ({} & {s: [for y in xc.undefined {}]}) != _|_ {a: 1} } oko2: { - if ({} & {s: [ for y in xo.undefined {}]}) != _|_ {a: 1} + if ({} & {s: [for y in xo.undefined {}]}) != _|_ {a: 1} } okc3: { - if ({s: [ for y in xc.undefined {}]}) != _|_ {a: 1} + if ({s: [for y in xc.undefined {}]}) != _|_ {a: 1} } oko3: { - if ({s: [ for y in xo.undefined {}]}) != _|_ {a: 1} + if ({s: [for y in xo.undefined {}]}) != _|_ {a: 1} } issue1969: okc: { let X = xc.undefined - let Y = {} & {s: [ for y in list.Range(0, X, 1) {}]} + let Y = {} & {s: [for y in list.Range(0, X, 1) {}]} if Y != _|_ {Y} } issue1969: oko: { let X = xo.undefined - let Y = {} & {s: [ for y in list.Range(0, X, 1) {}]} + let Y = {} & {s: [for y in list.Range(0, X, 1) {}]} if Y != _|_ {Y} } diff --git a/cue/testdata/comprehensions/incomplete.txtar b/cue/testdata/comprehensions/incomplete.txtar index 554c646f135..3cdc4f0551a 100644 --- a/cue/testdata/comprehensions/incomplete.txtar +++ b/cue/testdata/comprehensions/incomplete.txtar @@ -3,7 +3,7 @@ cond: bool src: {} top: _ a: [ if cond {}] -b: [ for x in src.foo {}] +b: [for x in src.foo {}] c: {for x in top {}} -- out/eval/stats -- Leaks: 0 @@ -27,7 +27,7 @@ Disjuncts: 7 } b: (_|_){ // [incomplete] b: undefined field: foo: - // ./in.cue:5:19 + // ./in.cue:5:18 } c: (_|_){ // [incomplete] c: cannot range over top (incomplete type _): diff --git a/cue/testdata/comprehensions/lists.txtar b/cue/testdata/comprehensions/lists.txtar index 2f866268a34..d85971129c1 100644 --- a/cue/testdata/comprehensions/lists.txtar +++ b/cue/testdata/comprehensions/lists.txtar @@ -1,7 +1,7 @@ -- in.cue -- a: [{a: 1}, {b: 2 & 3}] -b: [ for x in a {x}] +b: [for x in a {x}] -- out/eval/stats -- Leaks: 0 Freed: 7 diff --git a/cue/testdata/cycle/chain.txtar b/cue/testdata/cycle/chain.txtar index aeba45964fa..4926e6cec0f 100644 --- a/cue/testdata/cycle/chain.txtar +++ b/cue/testdata/cycle/chain.txtar @@ -100,7 +100,7 @@ issue2052: t1: { out: { if (#in & #basic) != _|_ {1} if (#in & #basic) == _|_ { - list.Max([ for k, v in #in {(#next & {#in: v}).out}]) + 1 + list.Max([for k, v in #in {(#next & {#in: v}).out}]) + 1 } } } @@ -139,7 +139,7 @@ issue2052: t2: { out: { if (#in & #basic) != _|_ {1} if (#in & #basic) == _|_ { - list.Max([ for k, v in #in {(#next & {#in: v}).out}]) + 1 + list.Max([for k, v in #in {(#next & {#in: v}).out}]) + 1 } } } @@ -188,7 +188,7 @@ issue2052: full: { // if we are not a basic type, then we are 1 + the max of children if (#in & #basic) == _|_ { // this is our "recursion" for each child - let depths = [ for k, v in #in {(#next & {#in: v}).out}] + let depths = [for k, v in #in {(#next & {#in: v}).out}] list.Max(depths) + 1 } } diff --git a/cue/testdata/cycle/comprehension.txtar b/cue/testdata/cycle/comprehension.txtar index f1af150e6b3..39de272a0df 100644 --- a/cue/testdata/cycle/comprehension.txtar +++ b/cue/testdata/cycle/comprehension.txtar @@ -4,11 +4,11 @@ A: { a: { parent: "" - children: [ for k, v in A if v.parent == k {k}] + children: [for k, v in A if v.parent == k {k}] } b: { parent: "a" - children: [ for k, v in A if v.parent == k {k}] + children: [for k, v in A if v.parent == k {k}] } } @@ -17,7 +17,7 @@ A: { B: { a: { parent: "" - children: [ for k, v in B for _, w in v.children {k}] + children: [for k, v in B for _, w in v.children {k}] } } @@ -131,13 +131,13 @@ selfReferential: acrossOr: t1: p1: { retry: #Output } - #Output: or([ for name, config in #AllOutputs { + #Output: or([for name, config in #AllOutputs { (name): config }]) } selfReferential: acrossOr: t1: p2: { - #Output: or([ for name, config in #AllOutputs { + #Output: or([for name, config in #AllOutputs { (name): config }]) @@ -151,7 +151,7 @@ selfReferential: acrossOr: t1: p2: { } selfReferential: acrossOr: t1: p3: { - #Output: or([ for name, config in #AllOutputs { + #Output: or([for name, config in #AllOutputs { (name): config }]) @@ -165,7 +165,7 @@ selfReferential: acrossOr: t1: p3: { } selfReferential: acrossOr: t2: p1: { - d: or([ for x, y in #A { y } ]) + d: or([for x, y in #A { y }]) o: d & { b: 2 } #A: { d1: int @@ -176,7 +176,7 @@ selfReferential: acrossOr: t2: p1: { selfReferential: acrossOr: t2: p2: { o: d & { b: 2 } - d: or([ for x, y in #A { y } ]) + d: or([for x, y in #A { y }]) #A: { d1: int d2: string @@ -191,7 +191,7 @@ selfReferential: acrossOr: t2: p3: { d2: string d3: b: d } - d: or([ for x, y in #A { y } ]) + d: or([for x, y in #A { y }]) } issue1881: p1: { @@ -203,7 +203,7 @@ issue1881: p1: { retry: output: #Output } - #Output: or([ for name, config in #AllOutputs { + #Output: or([for name, config in #AllOutputs { (name): config }]) } @@ -214,10 +214,10 @@ issue1881: p2: { resource: string retry: output: #Output } - + o: #Output & { retry: output: reject: "ok" } - #Output: or([ for name, config in #AllOutputs { + #Output: or([for name, config in #AllOutputs { (name): config }]) } @@ -229,7 +229,7 @@ issue1881: p3: { retry: output: #Output } - #Output: or([ for name, config in #AllOutputs { + #Output: or([for name, config in #AllOutputs { (name): config }]) diff --git a/cue/testdata/cycle/evaluate.txtar b/cue/testdata/cycle/evaluate.txtar index 2ea667ce5ca..03a92dd3dda 100644 --- a/cue/testdata/cycle/evaluate.txtar +++ b/cue/testdata/cycle/evaluate.txtar @@ -58,7 +58,7 @@ disjunctionCycle: { forCycle: { #A: a: #B // TODO(errors): Correct error position. - #B: or([ for x in #A { b: x } ]) + #B: or([for x in #A { b: x }]) } letCycleWithAnd: { diff --git a/cue/testdata/cycle/issue1960.txtar b/cue/testdata/cycle/issue1960.txtar index c42282744bc..0bc28d0e242 100644 --- a/cue/testdata/cycle/issue1960.txtar +++ b/cue/testdata/cycle/issue1960.txtar @@ -1,7 +1,7 @@ // Issue-specific tests. Essence tested in evaluate.txtar (LetCycle*). -- issue1960.cue -- t1: { - z: blah: s: [ for z in z {}] + z: blah: s: [for z in z {}] z: hello: { for x in p {} let q = z.blah @@ -11,7 +11,7 @@ t1: { } t2: { - z: blah: s: [ for z in z {}] + z: blah: s: [for z in z {}] z: hello: { for x in p {} let q = z.blah @@ -34,19 +34,19 @@ t3: { } } } - + #i: { #z t: "i" r: e: {} } - + #c: { #z t: "c" n: string } - + z: [N= =~"^b"]: #i & { s: [ for n, z in z @@ -54,7 +54,7 @@ t3: { if z.n == N {n}, ] } - + z: [N= =~"^h"]: #c & { n: string // Causes a structural cycle on its own, but not when referenced below. diff --git a/cue/testdata/cycle/structural.txtar b/cue/testdata/cycle/structural.txtar index 3696fffda01..259178bb131 100644 --- a/cue/testdata/cycle/structural.txtar +++ b/cue/testdata/cycle/structural.txtar @@ -189,7 +189,7 @@ b12b: { } // Issue #587 -b13: root: a: [ for x in root {x}] +b13: root: a: [for x in root {x}] // Issue #587 // TODO: this should probably be okay if we allow shallow evaluation of @@ -202,7 +202,7 @@ b14: { "\(x)": {} } - b: [ for x in root {x}] + b: [for x in root {x}] } } diff --git a/cue/testdata/definitions/issue317.txtar b/cue/testdata/definitions/issue317.txtar index 0186d9e42a8..8d47039c7c3 100644 --- a/cue/testdata/definitions/issue317.txtar +++ b/cue/testdata/definitions/issue317.txtar @@ -25,7 +25,7 @@ s: #T & { #Deployment: { #Containers: [Name=string]: #Container - containers: [ for c in #Containers {c}] // Problem is here. + containers: [for c in #Containers {c}] // Problem is here. } Something: { #Deployment @@ -150,7 +150,7 @@ s: #T & { #Deployment: { #Containers: [Name=string]: #Container - containers: [ for c in #Containers {c}] // Problem is here. + containers: [for c in #Containers {c}] // Problem is here. } Something: { #Deployment diff --git a/cue/testdata/definitions/issue491.txtar b/cue/testdata/definitions/issue491.txtar index 8a4cf831cf5..24e46a602a3 100644 --- a/cue/testdata/definitions/issue491.txtar +++ b/cue/testdata/definitions/issue491.txtar @@ -29,7 +29,7 @@ y: #Repo & { z: #PrestepNewUser & { Args: { - Repos: [ { + Repos: [{ Var: "REPO1" }] } diff --git a/cue/testdata/disjunctions/elimination.txtar b/cue/testdata/disjunctions/elimination.txtar index 30f3d410036..145f630ba57 100644 --- a/cue/testdata/disjunctions/elimination.txtar +++ b/cue/testdata/disjunctions/elimination.txtar @@ -382,7 +382,7 @@ issue2246: simplified: { #FormFoo: fooID: string #FormBar: barID: string #Form: { #FormFoo | #FormBar } - + data: {fooID: "123"} out1: #Form & data out2: #Form & out1 @@ -391,9 +391,9 @@ issue2246: full: { data: forms: [{ fooID: "00-0000001" }] - + form1040: (#compute & {in: data}).out - + #K1: { #_base: common: 3 #FormFoo: { @@ -408,16 +408,16 @@ issue2246: full: { #FormFoo | #FormBar } } - + #Input: { forms: [...#K1.#Form] } - + #summarizeReturn: { in: #Input - out: [ for k in in.forms { k.common } ] + out: [for k in in.forms { k.common }] } - + #compute: { in: #Input out: (#summarizeReturn & {"in": in}).out diff --git a/cue/testdata/eval/conjuncts.txtar b/cue/testdata/eval/conjuncts.txtar index 090753227fe..c834a58d8f8 100644 --- a/cue/testdata/eval/conjuncts.txtar +++ b/cue/testdata/eval/conjuncts.txtar @@ -34,7 +34,7 @@ issue2351: let: { let _param = "foo" ({ param: _param & [{}] - gen: [ for p in param {p}] + gen: [for p in param {p}] }).gen } @@ -42,7 +42,7 @@ issue2351: hidden: { _in1: ["foo"] { in2: _in1 - out: [ for x in in2 {x}] + out: [for x in in2 {x}] }.out } diff --git a/cue/testdata/eval/discontinuous.txtar b/cue/testdata/eval/discontinuous.txtar index 9a8187ca470..24caf8420ad 100644 --- a/cue/testdata/eval/discontinuous.txtar +++ b/cue/testdata/eval/discontinuous.txtar @@ -2,7 +2,7 @@ This test tests a case where a child node needs to be evaluated before evaluating a parent has completed. -- in.cue -- -a: [ for c in foo.bar.baz { +a: [for c in foo.bar.baz { c }] diff --git a/cue/testdata/eval/issue2146.txtar b/cue/testdata/eval/issue2146.txtar index ebc5c45c87d..b0f29d9a9d9 100644 --- a/cue/testdata/eval/issue2146.txtar +++ b/cue/testdata/eval/issue2146.txtar @@ -8,16 +8,16 @@ p1: { #A: { x?: int y?: int - + let list = [x, y] - all: [ for v in list if v != _|_ {v}] - + all: [for v in list if v != _|_ {v}] + *{ x?: _|_ y: 1 } | _ } - + a: #A & { x: 3 } b: #A & a } @@ -25,16 +25,16 @@ p2: { #A: { x?: int y?: int - + let list = [x, y] - all: [ for v in list if v != _|_ {v}] + all: [for v in list if v != _|_ {v}] _ | *{ x?: _|_ y: 1 } } - + a: #A & { x: 3, y: 2 } b: #A & a } diff --git a/cue/testdata/eval/let.txtar b/cue/testdata/eval/let.txtar index d7303a4cf18..506ba54cff4 100644 --- a/cue/testdata/eval/let.txtar +++ b/cue/testdata/eval/let.txtar @@ -28,7 +28,7 @@ issue1828: { volumes: L3 let L3 = { - for v2 in [ for v1 in L2 {} ] {} + for v2 in [for v1 in L2 {}] {} } let L2 = L1 diff --git a/cue/testdata/eval/lists.txtar b/cue/testdata/eval/lists.txtar index 19afa80f079..238f0c6a465 100644 --- a/cue/testdata/eval/lists.txtar +++ b/cue/testdata/eval/lists.txtar @@ -6,7 +6,7 @@ a: [1, 2, 3, d] b: a[3] d: 5 -c: [ for x in [[1, 2]][0] {x + d}] +c: [for x in [[1, 2]][0] {x + d}] -- out/eval/stats -- Leaks: 4 Freed: 11 diff --git a/cue/testdata/export/018.txtar b/cue/testdata/export/018.txtar index c35b04ab6f2..2dbc0cb2a04 100644 --- a/cue/testdata/export/018.txtar +++ b/cue/testdata/export/018.txtar @@ -2,7 +2,7 @@ # raw: true -- in.cue -- -{a: [1, 2], b: [ for k, v in a {v}]} +{a: [1, 2], b: [for k, v in a {v}]} -- out/def -- a: [1, 2] b: [1, 2] diff --git a/cue/testdata/fulleval/012_disjunctions_of_lists.txtar b/cue/testdata/fulleval/012_disjunctions_of_lists.txtar index 5605f9a9332..92544e71365 100644 --- a/cue/testdata/fulleval/012_disjunctions_of_lists.txtar +++ b/cue/testdata/fulleval/012_disjunctions_of_lists.txtar @@ -5,8 +5,8 @@ -- in.cue -- l: *[ int, int] | [ string, string] -l1: [ "a", "b"] -l2: l & [ "c", "d"] +l1: ["a", "b"] +l2: l & ["c", "d"] -- out/def -- l: *[int, int] | [string, string] l1: ["a", "b"] diff --git a/cue/testdata/fulleval/016_struct_comprehension_with_template.txtar b/cue/testdata/fulleval/016_struct_comprehension_with_template.txtar index a3b305cd854..5229a0ba49a 100644 --- a/cue/testdata/fulleval/016_struct_comprehension_with_template.txtar +++ b/cue/testdata/fulleval/016_struct_comprehension_with_template.txtar @@ -3,7 +3,7 @@ #name: struct comprehension with template #evalFull -- in.cue -- -result: [ for _, v in service {v}] +result: [for _, v in service {v}] service: [Name=string]: { name: *Name | string diff --git a/cue/testdata/fulleval/020_complex_interaction_of_groundness.txtar b/cue/testdata/fulleval/020_complex_interaction_of_groundness.txtar index 22b61268aea..41056611e86 100644 --- a/cue/testdata/fulleval/020_complex_interaction_of_groundness.txtar +++ b/cue/testdata/fulleval/020_complex_interaction_of_groundness.txtar @@ -3,7 +3,7 @@ #name: complex interaction of groundness #evalFull -- in.cue -- -res: [ for x in a for y in x {y & {d: "b"}}] +res: [for x in a for y in x {y & {d: "b"}}] res: [ a.b.c & {d: "b"}] a: b: [C=string]: {d: string, s: "a" + d} diff --git a/cue/testdata/fulleval/032_or_builtin_should_not_fail_on_non-concrete_empty_list.txtar b/cue/testdata/fulleval/032_or_builtin_should_not_fail_on_non-concrete_empty_list.txtar index 5594ce5b634..5fb45a426f5 100644 --- a/cue/testdata/fulleval/032_or_builtin_should_not_fail_on_non-concrete_empty_list.txtar +++ b/cue/testdata/fulleval/032_or_builtin_should_not_fail_on_non-concrete_empty_list.txtar @@ -8,7 +8,7 @@ [jobID=string]: { } } - #JobID: or([ for k, _ in jobs {k}]) + #JobID: or([for k, _ in jobs {k}]) } foo: #Workflow & { @@ -20,7 +20,7 @@ foo: #Workflow & { jobs: { [jobID=string]: {} } - #JobID: or([ for k, _ in jobs { k } ]) + #JobID: or([for k, _ in jobs { k }]) } foo: #Workflow & { jobs: { diff --git a/cue/testdata/fulleval/049_alias_reuse_in_nested_scope.txtar b/cue/testdata/fulleval/049_alias_reuse_in_nested_scope.txtar index 0ace4efd58d..88da14db0ed 100644 --- a/cue/testdata/fulleval/049_alias_reuse_in_nested_scope.txtar +++ b/cue/testdata/fulleval/049_alias_reuse_in_nested_scope.txtar @@ -4,7 +4,7 @@ #evalFull -- in.cue -- #Foo: { - let X = or([ for k, _ in {} {k}]) + let X = or([for k, _ in {} {k}]) connection: [X]: X } #A: { @@ -21,11 +21,11 @@ b: #B & {foo: "key"} -- out/def -- #Foo: { connection: { - [or([ for k, _ in { + [or([for k, _ in { ... - } { k } ])]: or([ for k, _ in { + } { k }])]: or([for k, _ in { ... - } { k } ]) + } { k }]) } } #A: { diff --git a/cue/testdata/references/let.txtar b/cue/testdata/references/let.txtar index ba1d5acfb48..412bd5dc1bb 100644 --- a/cue/testdata/references/let.txtar +++ b/cue/testdata/references/let.txtar @@ -15,15 +15,15 @@ a3: b: c: 100*A3[0] + A3[0] a4list: [{4}] let A4 = a4list -a4: [ for x in A4 {v: 404}] +a4: [for x in A4 {v: 404}] a5list: [{5}] let A5 = a5list -a5: b: [ for x in A5 {v: 505}] +a5: b: [for x in A5 {v: 505}] a6list: [{6}] let A6 = a6list -a6: b: c: [ for x in A6 {v: 606}] +a6: b: c: [for x in A6 {v: 606}] a7list: [{7}] let A7 = a7list diff --git a/cue/testdata/resolve/017_disjunctions_of_lists.txtar b/cue/testdata/resolve/017_disjunctions_of_lists.txtar index 25365d6dbdd..61521579b57 100644 --- a/cue/testdata/resolve/017_disjunctions_of_lists.txtar +++ b/cue/testdata/resolve/017_disjunctions_of_lists.txtar @@ -5,8 +5,8 @@ -- in.cue -- l: [ int, int] | [ string, string] -l1: [ "a", "b"] -l2: l & [ "c", "d"] +l1: ["a", "b"] +l2: l & ["c", "d"] -- out/def -- l: [int, int] | [string, string] l1: ["a", "b"] diff --git a/doc/ref/spec.md b/doc/ref/spec.md index fa8fd4ae3bd..47d4a5e9d59 100644 --- a/doc/ref/spec.md +++ b/doc/ref/spec.md @@ -2625,7 +2625,7 @@ LetClause = "let" identifier "=" Expression . ``` a: [1, 2, 3, 4] -b: [ for x in a if x > 1 { x+1 } ] // [3, 4, 5] +b: [for x in a if x > 1 { x+1 }] // [3, 4, 5] c: { for x in a diff --git a/doc/tutorial/basics/6_expressions/40_listcomp.txtar b/doc/tutorial/basics/6_expressions/40_listcomp.txtar index 35b6486de6c..d80ff7dc431 100644 --- a/doc/tutorial/basics/6_expressions/40_listcomp.txtar +++ b/doc/tutorial/basics/6_expressions/40_listcomp.txtar @@ -11,7 +11,7 @@ Lists can be created with list comprehensions. The example shows the use of `for` loops and `if` guards. -- listcomp.cue -- -[ for x in #items if x rem 2 == 0 { x*x } ] +[for x in #items if x rem 2 == 0 { x*x }] #items: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] diff --git a/doc/tutorial/basics/6_expressions/50_fieldcomp.txtar b/doc/tutorial/basics/6_expressions/50_fieldcomp.txtar index 706375afc16..9e7353bfb55 100644 --- a/doc/tutorial/basics/6_expressions/50_fieldcomp.txtar +++ b/doc/tutorial/basics/6_expressions/50_fieldcomp.txtar @@ -14,7 +14,7 @@ Instead, one must use indexing. -- fieldcomp.cue -- import "strings" -#a: [ "Barcelona", "Shanghai", "Munich" ] +#a: ["Barcelona", "Shanghai", "Munich"] for k, v in #a { "\( strings.ToLower(v) )": { diff --git a/doc/tutorial/basics/6_expressions/80_coalesce.txtar b/doc/tutorial/basics/6_expressions/80_coalesce.txtar index 8104bf7f318..d2a74e2c8a6 100644 --- a/doc/tutorial/basics/6_expressions/80_coalesce.txtar +++ b/doc/tutorial/basics/6_expressions/80_coalesce.txtar @@ -8,10 +8,10 @@ description = "" -- text.md -- @@ -28,7 +28,7 @@ In that case the default will be used if either the lookup fails or the result is not of the desired type. -- coalesce.cue -- -list: [ "Cat", "Mouse", "Dog" ] +list: ["Cat", "Mouse", "Dog"] a: *list[0] | "None" b: *list[5] | "None" diff --git a/doc/tutorial/kubernetes/README.md b/doc/tutorial/kubernetes/README.md index 91b125547ca..9b7c5c629ca 100644 --- a/doc/tutorial/kubernetes/README.md +++ b/doc/tutorial/kubernetes/README.md @@ -886,7 +886,7 @@ We create the tool file to do just that. $ cat < kube_tool.cue package kube -objects: [ for v in objectSets for x in v {x}] +objects: [for v in objectSets for x in v {x}] objectSets: [ service, @@ -1202,7 +1202,7 @@ The next step is to pull common fields, such as `image` to the top level. Arguments can be specified as a map. ``` arg: [string]: string - args: [ for k, v in arg { "-\(k)=\(v)" } ] | [...string] + args: [for k, v in arg { "-\(k)=\(v)" }] | [...string] ``` If order matters, users could explicitly specify the list as well. @@ -1307,7 +1307,7 @@ kubernetes: services: { metadata: labels: x.label spec: selector: x.label - spec: ports: [ for p in x.port { p } ] + spec: ports: [for p in x.port { p }] } } } diff --git a/doc/tutorial/kubernetes/manual/services/cloud.cue b/doc/tutorial/kubernetes/manual/services/cloud.cue index 0cbebccc25b..b7b524d44e6 100644 --- a/doc/tutorial/kubernetes/manual/services/cloud.cue +++ b/doc/tutorial/kubernetes/manual/services/cloud.cue @@ -26,7 +26,7 @@ deployment: [Name=_]: _base & { port: [string]: int arg: [string]: string - args: *[ for k, v in arg {"-\(k)=\(v)"}] | [...string] + args: *[for k, v in arg {"-\(k)=\(v)"}] | [...string] // Environment variables env: [string]: string diff --git a/doc/tutorial/kubernetes/manual/services/k8s.cue b/doc/tutorial/kubernetes/manual/services/k8s.cue index 25ce2f47f4a..2cdba67ffdb 100644 --- a/doc/tutorial/kubernetes/manual/services/k8s.cue +++ b/doc/tutorial/kubernetes/manual/services/k8s.cue @@ -10,7 +10,7 @@ kubernetes: services: { metadata: labels: x.label spec: selector: x.label - spec: ports: [ for p in x.port {p}] // convert struct to list + spec: ports: [for p in x.port {p}] // convert struct to list } } // Note that we cannot write @@ -84,10 +84,10 @@ _k8sSpec: X: kubernetes: { image: X.image args: X.args if len(X.envSpec) > 0 { - env: [ for k, v in X.envSpec {v, name: k}] + env: [for k, v in X.envSpec {v, name: k}] } - ports: [ for k, p in X.expose.port & X.port { + ports: [for k, p in X.expose.port & X.port { name: k containerPort: p }] diff --git a/doc/tutorial/kubernetes/manual/services/kube_tool.cue b/doc/tutorial/kubernetes/manual/services/kube_tool.cue index 0ca9d0f0eea..19fb18381bb 100644 --- a/doc/tutorial/kubernetes/manual/services/kube_tool.cue +++ b/doc/tutorial/kubernetes/manual/services/kube_tool.cue @@ -1,6 +1,6 @@ package kube -objects: [ for v in objectSets for x in v { x } ] +objects: [for v in objectSets for x in v { x }] objectSets: [ kubernetes.services, diff --git a/doc/tutorial/kubernetes/quick/services/kube_tool.cue b/doc/tutorial/kubernetes/quick/services/kube_tool.cue index c4e53e955e5..bb1dfa353ef 100644 --- a/doc/tutorial/kubernetes/quick/services/kube_tool.cue +++ b/doc/tutorial/kubernetes/quick/services/kube_tool.cue @@ -1,6 +1,6 @@ package kube -objects: [ for v in objectSets for x in v {x}] +objects: [for v in objectSets for x in v {x}] objectSets: [ service, diff --git a/encoding/protobuf/textproto/testdata/decoder/list.txtar b/encoding/protobuf/textproto/testdata/decoder/list.txtar index 49dc23083bd..829682a8105 100644 --- a/encoding/protobuf/textproto/testdata/decoder/list.txtar +++ b/encoding/protobuf/textproto/testdata/decoder/list.txtar @@ -16,7 +16,7 @@ string1: [...string] float1: [...number] -- input.textproto -- empty1: [] -empty2: [ # foo +empty2: [# foo ] int1: [1, 2] @@ -34,7 +34,7 @@ string1: [ float1: [ 1e+2 1. 0] -- out/decode -- empty1: [] -empty2: [ // foo +empty2: [// foo ] int1: [1, 2] int2: [1, 2] // omitting commas okay diff --git a/internal/ci/base/codereview.cue b/internal/ci/base/codereview.cue index 75bf11b19aa..113aab86a3d 100644 --- a/internal/ci/base/codereview.cue +++ b/internal/ci/base/codereview.cue @@ -21,7 +21,7 @@ import ( // the key: value toCodeReviewCfg: { #input: #codeReview - let parts = [ for k, v in #input {k + ": " + v}] + let parts = [for k, v in #input {k + ": " + v}] // Per https://pkg.go.dev/golang.org/x/review/git-codereview#hdr-Configuration strings.Join(parts, "\n") diff --git a/internal/ci/base/github.cue b/internal/ci/base/github.cue index a290574edad..ce3f15bf883 100644 --- a/internal/ci/base/github.cue +++ b/internal/ci/base/github.cue @@ -278,7 +278,7 @@ setupGoActionsCaches: { // but array literals are not yet supported in expressions. isProtectedBranch: { #trailers: [...string] - "((" + strings.Join([ for branch in protectedBranchPatterns { + "((" + strings.Join([for branch in protectedBranchPatterns { (_matchPattern & {variable: "github.ref", pattern: "refs/heads/\(branch)"}).expr }], " || ") + ") && (! \(containsDispatchTrailer)))" } diff --git a/internal/ci/ci_tool.cue b/internal/ci/ci_tool.cue index 358881e781e..e2f9068f8d9 100644 --- a/internal/ci/ci_tool.cue +++ b/internal/ci/ci_tool.cue @@ -55,7 +55,7 @@ command: gen: { for _workflowName, _workflow in github.workflows { let _filename = _workflowName + repo.workflowFileExtension "generate \(_filename)": file.Create & { - $after: [ for v in remove {v}] + $after: [for v in remove {v}] filename: path.Join([_dir, _filename], _goos) let donotedit = repo.doNotEditMessage & {#generatedBy: "internal/ci/ci_tool.cue", _} contents: "# \(donotedit)\n\n\(yaml.Marshal(_workflow))" diff --git a/internal/core/dep/testdata/dynamic.txtar b/internal/core/dep/testdata/dynamic.txtar index c8e78d582f6..3e7cb557ea3 100644 --- a/internal/core/dep/testdata/dynamic.txtar +++ b/internal/core/dep/testdata/dynamic.txtar @@ -19,7 +19,7 @@ middle: { } a: { - b: [ for x in middle {x}] + b: [for x in middle {x}] c: {} } -- out/dependencies/field -- diff --git a/internal/core/dep/testdata/listcomprehension.txtar b/internal/core/dep/testdata/listcomprehension.txtar index b16f5c5cf03..d7eb39074a6 100644 --- a/internal/core/dep/testdata/listcomprehension.txtar +++ b/internal/core/dep/testdata/listcomprehension.txtar @@ -1,5 +1,5 @@ -- in.cue -- -a: b: [ for x in c if x.a > 0 {x.a + d}] +a: b: [for x in c if x.a > 0 {x.a + d}] c: [{a: 1}, {a: 3}] d: 2 diff --git a/internal/core/export/testdata/main/let.txtar b/internal/core/export/testdata/main/let.txtar index bef12862840..3a42000a401 100644 --- a/internal/core/export/testdata/main/let.txtar +++ b/internal/core/export/testdata/main/let.txtar @@ -17,7 +17,7 @@ x: "foo" let Y = x y: Y -- issue593.cue -- -cfgs: [ for crd in ["one", "two"] { +cfgs: [for crd in ["one", "two"] { metadata: { name: crd } @@ -137,7 +137,7 @@ let X = 1 + 1 let Y = x let Y_1 = x { - cfgs: [ for crd in ["one", "two"] { + cfgs: [for crd in ["one", "two"] { metadata: { name: crd } diff --git a/internal/encoding/json/encode_test.go b/internal/encoding/json/encode_test.go index 921a40f7117..0bf00d0c840 100644 --- a/internal/encoding/json/encode_test.go +++ b/internal/encoding/json/encode_test.go @@ -154,7 +154,7 @@ f4: { a: 1 b: 3 } - c: [1, [ for x in m { x } ]] + c: [1, [for x in m { x }]] `, out: "json: unsupported node for x in m {x} (*ast.Comprehension)", }, { diff --git a/internal/encoding/yaml/encode_test.go b/internal/encoding/yaml/encode_test.go index 1ca03d5183c..a21a21f799f 100644 --- a/internal/encoding/yaml/encode_test.go +++ b/internal/encoding/yaml/encode_test.go @@ -170,7 +170,7 @@ f4: {} # line 4 a: 1 b: 3 } - c: [1, [ for x in m {x}]] + c: [1, [for x in m {x}]] `, out: "yaml: unsupported node for x in m {x} (*ast.Comprehension)", }, { diff --git a/pkg/list/list.go b/pkg/list/list.go index 9fadb66d0da..5bf55fbafca 100644 --- a/pkg/list/list.go +++ b/pkg/list/list.go @@ -149,7 +149,7 @@ func Repeat(x []cue.Value, count int) ([]cue.Value, error) { // // Concat([a, b, c]) is equivalent to // -// [ for x in a {x}, for x in b {x}, for x in c {x} ] +// [for x in a {x}, for x in b {x}, for x in c {x}] func Concat(a []cue.Value) ([]cue.Value, error) { var res []cue.Value for _, e := range a { diff --git a/pkg/tool/exec/exec_test.go b/pkg/tool/exec/exec_test.go index 211caa871d0..5af105c1092 100644 --- a/pkg/tool/exec/exec_test.go +++ b/pkg/tool/exec/exec_test.go @@ -43,7 +43,7 @@ func TestEnv(t *testing.T) { }, { val: ` cmd: "echo" - env: [ "WHO=World", "WHAT=Hello", "WHEN=Now!" ] + env: ["WHO=World", "WHAT=Hello", "WHEN=Now!"] `, env: []string{"WHO=World", "WHAT=Hello", "WHEN=Now!"}, }} diff --git a/tools/flow/testdata/dep.txtar b/tools/flow/testdata/dep.txtar index 17e11636e5b..23028fcfb22 100644 --- a/tools/flow/testdata/dep.txtar +++ b/tools/flow/testdata/dep.txtar @@ -52,7 +52,7 @@ root: { } incompleteList: { - x: [ for x in [1] {incompleteComprehensionSource.x}] + x: [for x in [1] {incompleteComprehensionSource.x}] } incompleteGeneratedStruct: { diff --git a/tools/flow/testdata/dynamic.txtar b/tools/flow/testdata/dynamic.txtar index efd2a1c9ea9..e9c4aa57efe 100644 --- a/tools/flow/testdata/dynamic.txtar +++ b/tools/flow/testdata/dynamic.txtar @@ -16,7 +16,7 @@ root: { // Run this after all generated tasks (so far) b: { $id: "list" - $after: [ for x in middle {x}] + $after: [for x in middle {x}] out: [...int] } after: { diff --git a/tools/flow/testdata/issue2416b.txtar b/tools/flow/testdata/issue2416b.txtar index 7ba67ef59ab..bf1ddc1362e 100644 --- a/tools/flow/testdata/issue2416b.txtar +++ b/tools/flow/testdata/issue2416b.txtar @@ -22,7 +22,7 @@ for _, input in inputs { } root: print: cli.Print & { - text: strings.Join([ for key, val in outputs { "key=\(key) val=\(val)" } ], "\n") + text: strings.Join([for key, val in outputs { "key=\(key) val=\(val)" }], "\n") } -- out/run/errors -- -- out/run/t0 -- diff --git a/tools/trim/testdata/defaults.txtar b/tools/trim/testdata/defaults.txtar index 22fec7cef7c..bb6236ae00f 100644 --- a/tools/trim/testdata/defaults.txtar +++ b/tools/trim/testdata/defaults.txtar @@ -59,7 +59,7 @@ issue781: { // was first used to select the default. dontEraseDefaultSelection: { rule: _#Rule & { - verbs: [ "c"] + verbs: ["c"] } _#Rule: { verbs: *["a", "b"] | ["c"] @@ -127,7 +127,7 @@ issue781: { // was first used to select the default. dontEraseDefaultSelection: { rule: _#Rule & { - verbs: [ "c"] + verbs: ["c"] } _#Rule: { verbs: *["a", "b"] | ["c"]