Skip to content

Commit

Permalink
Fix type-unaware target collection (#340)
Browse files Browse the repository at this point in the history
* Disable type-unware target collection for complex expressions

* Don't create type-aware targets for attributes without `AsExprType` enabled

* Fix type-unaware target collection for attributes
  • Loading branch information
dbanck authored Nov 3, 2023
1 parent fc59723 commit 2ce7ad1
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 838 deletions.
9 changes: 2 additions & 7 deletions decoder/expr_any_ref_targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (a Any) ReferenceTargets(ctx context.Context, targetCtx *TargetContext) ref
}
}

if targetCtx == nil || len(targetCtx.ParentAddress) == 0 {
if targetCtx == nil || len(targetCtx.ParentAddress) == 0 || !targetCtx.AsExprType {
return reference.Targets{}
}

Expand All @@ -34,11 +34,6 @@ func (a Any) ReferenceTargets(ctx context.Context, targetCtx *TargetContext) ref
rangePtr = a.expr.Range().Ptr()
}

var refType cty.Type
if targetCtx.AsExprType {
refType = typ
}

return reference.Targets{
{
Addr: targetCtx.ParentAddress,
Expand All @@ -47,7 +42,7 @@ func (a Any) ReferenceTargets(ctx context.Context, targetCtx *TargetContext) ref
ScopeId: targetCtx.ScopeId,
RangePtr: rangePtr,
DefRangePtr: targetCtx.ParentDefRangePtr,
Type: refType,
Type: typ,
},
}
}
Expand Down
Loading

0 comments on commit 2ce7ad1

Please sign in to comment.