Skip to content

Commit

Permalink
gopls/internal/analysis/yield: analyzer for iterator (yield) mistakes
Browse files Browse the repository at this point in the history
This analyzer detects failure to check the result of a call to
yield (which can cause a range loop to run beyond the sequence,
leading to a panic).

It is not always a mistake to ignore the
result of a call to yield; it depends on whether control can
reach another call to yield without checking that the first
call returned true. Consequently, this analyzer uses SSA
for control flow analysis.

We plan to add this analyzer to gopls before we promote it to vet.

+ test, relnote

Fixes golang/go#65795

Change-Id: I75fa272e2f546be0c2acb10a1978c82bc19db5bd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/609617
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
adonovan authored and dennypenta committed Dec 3, 2024
1 parent 7a4f3b0 commit c0933d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gopls/internal/doc/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -1353,4 +1353,4 @@
"Default": false
}
]
}
}

0 comments on commit c0933d0

Please sign in to comment.