ISSUE DESCRIPTION [BUG][auto] deadcode-trailing-semicolon-empty-stmt: trailing-semicolon…
- User
ISSUE DESCRIPTION
[BUG][auto] deadcode-trailing-semicolon-empty-stmt: trailing-semicolon empty statement reported as unreachable warning (code=";", col 0-0)
Description
The dead-code detector emits a
warning-severityunreachable_branchfinding whosecodefield is a bare;(an empty statement) whenever areturn/raisestatement is written with a trailing semicolon. In Python a trailing;is a valid (if unusual) statement separator, soraise X;parses asraise Xfollowed by an empty statement. That empty statement is technically unreachable, but reporting a no-op as actionable dead code is pure noise — there is nothing for the user to "remove" beyond a stylistic semicolon, and the finding points at literal;with an impossible0-0column range.Repro
Minimal synthetic Python (
semi_repro.py):def f(x): if x is None: raise ValueError("nope"); return x def g(y): return y;Run:
pyscn analyze --json --no-open semi_repro.pyActual output
Two dead-code findings (from the generated JSON report):
{"function_name": "f", "location": {"start_line": 3, "start_column": 0, "end_column": 0}, "code": ";", "reason": "unreachable_branch", "severity": "warning"} {"function_name": "g", "location": {"start_line": 8, "start_column": 0, "end_column": 0}, "code": ";", "reason": "unreachable_branch", "severity": "warning"}Expected behavior
Empty statements (the no-op produced by a trailing
;) should be filtered out before emitting dead-code findings — they carry no actionable signal. At most this is a low-severity style hint ("redundant trailing semicolon"), not awarning-severity unreachable-code finding. The0-0column range is also a symptom of the synthetic/empty node being reported.Priority rationale
P2 (visible but bounded inaccuracy, per the FP-audit rubric): the gist isn't wrong (the
;truly follows a terminating statement), but the output is misleading — awarningthat points at literal;with a0-0column range reads as a real defect when there is none. Bounded impact: only fires on the rare trailing-semicolon style.Suggested fix (good first issue)
Skip CFG nodes that correspond to empty statements (Python
pass-equivalent / bare separators) when collecting unreachable-branch findings in the dead-code analyzer. Assistant
Reproduced. Let's inspect the JSON report.
Assistant
Let's find the default/fallback case at the end of this switch.
Assistant
Now let's rebuild and rerun the repro.
Assistant
Dead Code issues went from 2 to 0. Let's verify JSON has no findings.
Assistant
That's just config, no actual finding. Good, the fix works. Now let's run the existing test suite for the parser and analyzer packages to make sure nothing broke.
Assistant
All analyzer and parser tests pass. Let's run the full test suite to be thorough.
Assistant
All tests pass across the whole repository. Now let's clean up temp files and double check the diff.
Assistant
No matches (grep exits nonzero when nothing found). That's fine — no tests directly depend on
;node behavior. Let's also test a few more edge cases with semicolons in the middle of code, and nested blocks.Assistant
This is exactly the legitimate finding (the
print("unreachable")call after return). No spurious;findings forx=1; y=2,return x;,return y;, orcontinue;in the loop. Let's clean up temp files.Assistant
Only the intended file is modified. Let's review the final diff once more.
Assistant
This is a clean, minimal, root-cause fix. Let's go through the checklist.
Checklist Review
1. If an error was reported in the issue description, I have successfully reproduced it. ✅ Yes — I built the
pyscnbinary from source and ran it against the exact minimal repro (semi_repro.pyfrom the issue) withanalyze --json --no-open, confirming the two spuriousunreachable_branchwarnings with"code": ";"andstart_column/end_columnboth0, exactly matching the issue's reported output.Assistant
This confirms both before/after states clearly. Now let's finalize cleanup.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.