Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new guard still prevents resolution when an enclosing label directly labels the goto statement.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes Go CFG resolution for goto statements targeting enclosing and stacked labels.
Changes:
- Extends Go-specific goto target handling to enclosing labels.
- Adds an inline CFG regression test for stacked labels.
| File | Description |
|---|---|
ControlFlowGraphImpl.qll |
Resolves additional enclosing goto targets. |
GotoTarget.ql |
Defines inline CFG assertions. |
gotos.go |
Adds stacked-label test cases. |
GotoTarget.expected |
Adds the generated expected baseline. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
owen-mc
force-pushed
the
go/fix/cfg-nested-labels
branch
from
September 25, 2026 15:51
7de00b0 to
cb2024e
Compare
owen-mc
force-pushed
the
go/fix/cfg-nested-labels
branch
from
September 25, 2026 15:53
cb2024e to
fba894a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fix Go CFG construction for
gotostatements targeting an enclosing label, including the inner label in stacked labels.Problem
The shared CFG logic resolves goto targets that are sibling statements in the same block. It did not handle this pattern:
outer: inner: { goto inner }Here,
innerencloses the current block rather than appearing inside it. The goto completion therefore failed to reach its target.This kind of code is rarely written by hand, but is commonly generated by parser generators.
Fix
We already have Go-specific goto handling to cover targets that the shared block logic cannot see. Currently it just covers Top-level statements in function bodies.. In this PR we extend it to labels enclosing the current node.
The target is matched against the direct
LabeledStmt, ensuring stacked labels such asinnerandouterremain distinct.A focused CFG regression test covers all gotos in the stacked-label example and demonstrates the missing
inneredge before the fix.I have validated this fixed some incorrect alert changes in real projects.
This does not need a change note because it fixes FPs that have never been in a release.