Skip to content

Commit

Permalink
TEMP: Reproduction of crasher of invalid case in splat eval
Browse files Browse the repository at this point in the history
  • Loading branch information
apparentlymart committed Jan 3, 2025
1 parent 923b06b commit ead0f8c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions hclsyntax/expression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ead0f8c

Please sign in to comment.