hclsyntax: Fix panic for marked collection splat
This commit is contained in:
parent
94940f55d6
commit
7f17fe4202
@ -1452,6 +1452,9 @@ func (e *SplatExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
|
|||||||
return cty.UnknownVal(ty), diags
|
return cty.UnknownVal(ty), diags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unmark the collection, and save the marks to apply to the returned
|
||||||
|
// collection result
|
||||||
|
sourceVal, marks := sourceVal.Unmark()
|
||||||
vals := make([]cty.Value, 0, sourceVal.LengthInt())
|
vals := make([]cty.Value, 0, sourceVal.LengthInt())
|
||||||
it := sourceVal.ElementIterator()
|
it := sourceVal.ElementIterator()
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
@ -1486,9 +1489,9 @@ func (e *SplatExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
|
|||||||
diags = append(diags, tyDiags...)
|
diags = append(diags, tyDiags...)
|
||||||
return cty.ListValEmpty(ty.ElementType()), diags
|
return cty.ListValEmpty(ty.ElementType()), diags
|
||||||
}
|
}
|
||||||
return cty.ListVal(vals), diags
|
return cty.ListVal(vals).WithMarks(marks), diags
|
||||||
default:
|
default:
|
||||||
return cty.TupleVal(vals), diags
|
return cty.TupleVal(vals).WithMarks(marks), diags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,7 +1156,22 @@ upper(
|
|||||||
}),
|
}),
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
|
{ // splat with sensitive collection
|
||||||
|
`maps.*.enabled`,
|
||||||
|
&hcl.EvalContext{
|
||||||
|
Variables: map[string]cty.Value{
|
||||||
|
"maps": cty.ListVal([]cty.Value{
|
||||||
|
cty.MapVal(map[string]cty.Value{"enabled": cty.True}),
|
||||||
|
cty.MapVal(map[string]cty.Value{"enabled": cty.False}),
|
||||||
|
}).Mark("sensitive"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cty.ListVal([]cty.Value{
|
||||||
|
cty.True,
|
||||||
|
cty.False,
|
||||||
|
}).Mark("sensitive"),
|
||||||
|
0,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
`["hello"][0]`,
|
`["hello"][0]`,
|
||||||
nil,
|
nil,
|
||||||
|
Loading…
Reference in New Issue
Block a user