Skip to content

Commit c1dc30b

Browse files
adonovandennypenta
authored andcommitted
gopls/internal/analysis/yield: add comment about dataflow
This comment is the residue of futile couple of hours last week playing with more sophisticated approaches to fixing golang/go#70598 Updates golang/go#70598 Change-Id: I92fc5433189ae4558aa615bdafb7e680e8636b2e Reviewed-on: https://go-review.googlesource.com/c/tools/+/633196 Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent c0933d0 commit c1dc30b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

gopls/internal/analysis/yield/yield.go

+15
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ func run(pass *analysis.Pass) (interface{}, error) {
9393
// yield call to another yield call--possible the same one,
9494
// following all block successors except "if yield() { ... }";
9595
// in such cases we know that yield returned true.
96+
//
97+
// Note that this is a "may" dataflow analysis: it
98+
// reports when a yield function _may_ be called again
99+
// without a positive intervening check, but it is
100+
// possible that the check is beyond the ability of
101+
// the representation to detect, perhaps involving
102+
// sophisticated use of booleans, indirect state (not
103+
// in SSA registers), or multiple flow paths some of
104+
// which are infeasible.
105+
//
106+
// A "must" analysis (which would report when a second
107+
// yield call can only be reached after failing the
108+
// boolean check) would be too conservative.
109+
// In particular, the most common mistake is to
110+
// forget to check the boolean at all.
96111
for call, info := range ssaYieldCalls {
97112
visited := make([]bool, len(fn.Blocks)) // visited BasicBlock.Indexes
98113

0 commit comments

Comments
 (0)