Skip to content

Commit

Permalink
fix: Avoid collecting non-addressable attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Mar 20, 2023
1 parent 7bb1cd0 commit 9bacc5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions decoder/expr_list_ref_targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
7 changes: 7 additions & 0 deletions decoder/expr_tuple_ref_targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 9bacc5a

Please sign in to comment.