diff --git a/hclsyntax/expression.go b/hclsyntax/expression.go index 7576781..ca59461 100644 --- a/hclsyntax/expression.go +++ b/hclsyntax/expression.go @@ -1320,12 +1320,6 @@ 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 @@ -1349,6 +1343,13 @@ func (e *SplatExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) { return cty.DynamicVal, diags } + 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 + } + if autoUpgrade { sourceVal = cty.TupleVal([]cty.Value{sourceVal}) sourceTy = sourceVal.Type() diff --git a/hclsyntax/expression_test.go b/hclsyntax/expression_test.go index 8faa2ec..f4b4fdf 100644 --- a/hclsyntax/expression_test.go +++ b/hclsyntax/expression_test.go @@ -907,6 +907,12 @@ upper( }), 0, }, + { + `null[*]`, + nil, + cty.EmptyTupleVal, + 0, + }, { `{name: "Steve"}[*].name`, nil,