Skip to content

fix(js): give a dead region the reason of the terminator that starts it - #211

Merged
DaisukeYoda merged 2 commits into
mainfrom
fix/dead-code-region-reason
Oct 15, 2026
Merged

DaisukeYoda merged 2 commits into
mainfrom
fix/dead-code-region-reason

Conversation

@DaisukeYoda

Copy link
Copy Markdown
Member

Ports pyscn 175de1f (pyscn#471), which jscan/SYNC.md held back until #172 was fixed.

A dead block took its reason from the last statement of a predecessor or from its own label. A block further down a dead region, such as the body of an if, a loop or a catch after a return, matched neither, so it was reported as an unreachable_branch warning. Findings of different reasons are not merged, so one dead region came out as several findings.

The detector now walks forward from each block the CFG builder created after a return, throw, break or continue. Every unreachable block on that walk takes that terminator's reason and critical severity, so the region merges into one finding.

A closing } is not a CFG statement, so a region whose nested if or loop ends before more dead code is still split at that line. jscan/SYNC.md records this gap. On imbue-ai/latchkey and sindresorhus/got the findings do not change.

@DaisukeYoda
DaisukeYoda merged commit 0971451 into main Oct 15, 2026
4 checks passed
@DaisukeYoda
DaisukeYoda deleted the fix/dead-code-region-reason branch October 15, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant