diff --git a/compiler/desugar.go b/compiler/desugar.go index 456b082..520bcbd 100644 --- a/compiler/desugar.go +++ b/compiler/desugar.go @@ -802,7 +802,13 @@ func (d *desugarer) decomposeExpression(expr ast.Expr, flags exprFlags) (ast.Exp case *ast.CompositeLit: for i, elt := range e.Elts { - e.Elts[i] = decompose(elt) + switch kv := elt.(type) { + case *ast.KeyValueExpr: + kv.Key = decompose(kv.Key) + kv.Value = decompose(kv.Value) + default: + e.Elts[i] = decompose(elt) + } } // skip e.Type (type expression) diff --git a/compiler/desugar_test.go b/compiler/desugar_test.go index 9eefaa2..cff676d 100644 --- a/compiler/desugar_test.go +++ b/compiler/desugar_test.go @@ -1063,6 +1063,20 @@ _l0: _v0 := e() a, b, c = d(_v0) } +`, + }, + { + name: "key value expr", + body: "Foo{Bar: a(b()), Baz: c(d())}", + // TODO: fix order of evaluation here + expect: ` +{ + _v3 := d() + _v2 := b() + _v1 := c(_v3) + _v0 := a(_v2) + Foo{Bar: _v0, Baz: _v1} +} `, }, } {