Skip to content

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sonalmahajan15 committed Oct 19, 2023
1 parent 2c49345 commit 67d7ac3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions assertion/function/assertiontree/backprop.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,9 @@ buildShadowMask:
}

lhsNode, ok := rootNode.LiftFromPath(lpath)
if ok {
// TODO: below check for `lhsNode != nil` should not be needed when NilAway supports Ok form for
// used-defined functions (tracked issue #77)
if ok && lhsNode != nil {
// Add assignment entries to the consumers of lhsNode for informative printing of errors
for _, c := range lhsNode.ConsumeTriggers() {
c.Annotation.AddAssignment(annotation.Assignment{
Expand Down Expand Up @@ -622,12 +624,14 @@ buildShadowMask:
afterLastIndex := len(rootNode.triggers)

// Update consumers of newly added triggers with assignment entries for informative printing of errors
for _, t := range rootNode.triggers[beforeLastIndex:afterLastIndex] {
t.Consumer.Annotation.AddAssignment(annotation.Assignment{
LHSExprStr: util.ExprToString(lhsVal, rootNode.Pass()),
RHSExprStr: util.ExprToString(rhsVal, rootNode.Pass()),
Position: util.TruncatePosition(util.PosToLocation(lhsVal.Pos(), rootNode.Pass())),
})
if len(rootNode.triggers) > beforeLastIndex && len(rootNode.triggers) <= afterLastIndex {
for _, t := range rootNode.triggers[beforeLastIndex:afterLastIndex] {
t.Consumer.Annotation.AddAssignment(annotation.Assignment{
LHSExprStr: util.ExprToString(lhsVal, rootNode.Pass()),
RHSExprStr: util.ExprToString(rhsVal, rootNode.Pass()),
Position: util.TruncatePosition(util.PosToLocation(lhsVal.Pos(), rootNode.Pass())),
})
}
}
default:
return errors.New("rhs expression in a 1-1 assignment was multiply returning - " +
Expand Down

0 comments on commit 67d7ac3

Please sign in to comment.