Skip to content

Commit

Permalink
cue/format: format let clause
Browse files Browse the repository at this point in the history
Change-Id: Icced6313704dba566ae9c8138238b5626367945e
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7850
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Dec 3, 2020
1 parent fb3b02e commit fe73e8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cue/format/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,14 @@ func (f *formatter) clause(clause ast.Clause) {
f.expr(n.Condition)
f.markUnindentLine()

case *ast.LetClause:
f.print(n.Let, token.LET, blank, nooverride)
f.print(indent)
f.expr(n.Ident)
f.print(blank, nooverride, n.Equal, token.BIND, blank)
f.expr(n.Expr)
f.markUnindentLine()

default:
panic("unknown clause type")
}
Expand Down
3 changes: 2 additions & 1 deletion cue/format/testdata/expressions.golden
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ package expressions

e: {
for k, v in someObject
let x = v
if k > "a" {
"\(k)": v
"\(k)": x
}}

if a |
Expand Down
3 changes: 2 additions & 1 deletion cue/format/testdata/expressions.input
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ package expressions

e: {
for k, v in someObject
let x = v
if k > "a" {
"\(k)":v}}
"\(k)":x}}

if a |
b {
Expand Down

0 comments on commit fe73e8f

Please sign in to comment.