diff --git a/hclsyntax/expression_test.go b/hclsyntax/expression_test.go index 843847df..598e2116 100644 --- a/hclsyntax/expression_test.go +++ b/hclsyntax/expression_test.go @@ -1387,6 +1387,50 @@ upper( cty.DynamicVal, 1, // splat cannot be applied to null sequence }, + { + `listofobj[*].scalar[*]`, + &hcl.EvalContext{ + Variables: map[string]cty.Value{ + "listofobj": cty.ListVal([]cty.Value{ + cty.ObjectVal(map[string]cty.Value{ + "scalar": cty.StringVal("foo"), + }), + cty.ObjectVal(map[string]cty.Value{ + "scalar": cty.StringVal("bar"), + }), + }), + }, + }, + cty.ListVal([]cty.Value{ + // The second-level splat promotes the scalars to single-element tuples. + cty.TupleVal([]cty.Value{cty.StringVal("foo")}), + cty.TupleVal([]cty.Value{cty.StringVal("bar")}), + }), + 0, // splat cannot be applied to null sequence + }, + { + `listofobj[*].scalar[*]`, + &hcl.EvalContext{ + Variables: map[string]cty.Value{ + "listofobj": cty.ListVal([]cty.Value{ + cty.ObjectVal(map[string]cty.Value{ + "scalar": cty.NullVal(cty.String), + }), + cty.ObjectVal(map[string]cty.Value{ + "scalar": cty.StringVal("bar"), + }), + }), + }, + }, + cty.ListVal([]cty.Value{ + // FIXME: The expected result of this is actually impossible because + // a list can't contain both an empty tuple and a single-element tuple + // at the same time. Therefore this actually panics. + cty.EmptyTupleVal, + cty.TupleVal([]cty.Value{cty.StringVal("bar")}), + }), + 0, // splat cannot be applied to null sequence + }, { `["hello", "goodbye"].*`, nil,