diff --git a/hcl/hclsyntax/expression.go b/hcl/hclsyntax/expression.go index 5a523ed..91da3fc 100644 --- a/hcl/hclsyntax/expression.go +++ b/hcl/hclsyntax/expression.go @@ -1228,6 +1228,12 @@ func (e *SplatExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) { } sourceTy := sourceVal.Type() + if sourceTy == cty.DynamicPseudoType { + // If we don't even know the _type_ of our source value yet then + // we'll need to defer all processing, since we can't decide our + // result type either. + return cty.DynamicVal, diags + } // A "special power" of splat expressions is that they can be applied // both to tuples/lists and to other values, and in the latter case diff --git a/hcl/hclsyntax/expression_test.go b/hcl/hclsyntax/expression_test.go index ad8437f..48cf3bc 100644 --- a/hcl/hclsyntax/expression_test.go +++ b/hcl/hclsyntax/expression_test.go @@ -759,6 +759,16 @@ upper( cty.UnknownVal(cty.Tuple([]cty.Type{cty.DynamicPseudoType})), 1, // a string has no attribute "name" }, + { + `dyn.*.name`, + &hcl.EvalContext{ + Variables: map[string]cty.Value{ + "dyn": cty.DynamicVal, + }, + }, + cty.DynamicVal, + 0, + }, { `unkobj.*.name`, &hcl.EvalContext{