[tools] gopls/internal/analysis/yield: handle booleans better

0 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Oct 22, 2025, 4:00:50 PM (17 hours ago) Oct 22
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Markus Kusano, Go LUCI, golang-co...@googlegroups.com

Alan Donovan submitted the change

Change information

Commit message:
gopls/internal/analysis/yield: handle booleans better

This change improves the analysis of control flow conditions,
especially in the presence of conditions materialized
as booleans.

Previously, we would peephole-optimize conditions
of the form phi(false, ..., yield), but not cases such as
phi(false, phi(false, ..., yield), yield). Now we apply
the optimization to all leaves of the phi graph.

Happily, the only test failure encountered while making
this change was the one that intentionally recorded the
limitation of the old algorithm. Sadly, it took me a while
to notice that this failure was a good thing and stop
futzing with my logic!

+ tests

Fixes golang/go#74136
Fixes golang/go#75924
Change-Id: I474d303a728400c37a8dfbbdf1b5172372137d1c
Reviewed-by: Markus Kusano <kus...@google.com>
Files:
  • M gopls/internal/analysis/yield/testdata/src/a/a.go
  • M gopls/internal/analysis/yield/yield.go
Change size: L
Delta: 2 files changed, 205 insertions(+), 92 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Markus Kusano
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I474d303a728400c37a8dfbbdf1b5172372137d1c
Gerrit-Change-Number: 712401
Gerrit-PatchSet: 4
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Markus Kusano <kus...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages