diff --git a/decoder/expr_list_ref_targets.go b/decoder/expr_list_ref_targets.go index e29b3df1..22b3969c 100644 --- a/decoder/expr_list_ref_targets.go +++ b/decoder/expr_list_ref_targets.go @@ -25,6 +25,13 @@ func (list List) ReferenceTargets(ctx context.Context, targetCtx *TargetContext) for i, elemExpr := range eType.Exprs { expr := newExpression(list.pathCtx, elemExpr, list.cons.Elem) if e, ok := expr.(ReferenceTargetsExpression); ok { + if targetCtx == nil { + // collect any targets inside the expression + // if attribute itself isn't targetable + elemTargets = append(elemTargets, e.ReferenceTargets(ctx, nil)...) + continue + } + elemCtx := targetCtx.Copy() elemCtx.ParentAddress = append(elemCtx.ParentAddress, lang.IndexStep{ Key: cty.NumberIntVal(int64(i)), diff --git a/decoder/expr_tuple_ref_targets.go b/decoder/expr_tuple_ref_targets.go index 157cd04e..60ff74c0 100644 --- a/decoder/expr_tuple_ref_targets.go +++ b/decoder/expr_tuple_ref_targets.go @@ -28,6 +28,13 @@ func (tuple Tuple) ReferenceTargets(ctx context.Context, targetCtx *TargetContex expr := newExpression(tuple.pathCtx, elemExpr, tuple.cons.Elems[i]) if e, ok := expr.(ReferenceTargetsExpression); ok { + if targetCtx == nil { + // collect any targets inside the expression + // if attribute itself isn't targetable + elemTargets = append(elemTargets, e.ReferenceTargets(ctx, nil)...) + continue + } + elemCtx := targetCtx.Copy() elemCtx.ParentAddress = append(elemCtx.ParentAddress, lang.IndexStep{ Key: cty.NumberIntVal(int64(i)),