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):pythondef f(x): if x is None: raise ValueError("nope"); return x def g(y): return y;Run:
bashpyscn analyze --json --no-open semi_repro.pyActual output
Two dead-code findings (from the generated JSON report):
json{"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 — a that points at literal with a column range reads as a real defect when there is none. Bounded impact: only fires on the rare trailing-semicolon style.
- Assistant
I’ll first map the dead-code analyzer and its tests, then reproduce the reported behavior with the project’s own CLI or test harness. I’ll implement the narrowest filtering at the point unreachable findings are collected, verify both the reproduction and relevant existing tests, and inspect the final diff before submission.
- Assistant
The repository is Go-based, and the likely implementation is
internal/analyzer/dead_code.go; service tests may only validate formatting, so I’m now tracing the CFG node model and dead-code collection logic to determine how an empty statement is represented and where a semantic filter belongs. - Assistant
The parser has an explicit
NodePass, and CFG blocks retain parser nodes. This strongly matches the issue’s “pass-equivalent / bare;” wording. I’ll reproduce to confirm the trailing separator is represented asNodePass, then filter only dead blocks whose actionable statements are absent—without suppressing genuine unreachablepassstatements, which are valid user-written code and may still be meaningful. - Assistant
The reproduction command is currently blocked by an environment configuration issue (
GOMODCACHE/GOPATHare unset), not by the code. The source confirmsNodePassis normally removed by an AST simplifier, but the reported semicolon survives far enough to become a CFG statement. I’ll use a temporary Go cache location to run the CLI and inspect the exact node behavior. - Assistant
The output confirms the bug: the CLI reports two findings and the generated report contains
code: ";". SincegetNodeDescriptionwould renderNodePassas"pass", the semicolon is a distinct parser node type (likely punctuation), not an ordinarypass. I’ll inspect the parsed AST/CFG node types and locations directly so the filter targets only this synthetic empty node rather than all pass statements. - Assistant
The AST inspection identifies the exact synthetic node: type
";", location on the semicolon itself. It forms its own unreachable CFG block, while realpassis typePass. I’ll add a detector-local predicate for the semicolon node and exclude blocks containing only such nodes from both findings and dead-block accounting; mixed blocks remain reportable. - Assistant
The change is implemented with block-level accounting: semicolon-only unreachable blocks are ignored, while explicit
passand any block containing a real statement are preserved. I’ll now rerun the reproduction and focused analyzer/service tests, then run the full Go test suite if those pass. - Assistant
The reproduction is fixed: dead-code score is now 100 with zero issues, and focused analyzer/service tests pass. I’ll perform a broader test run and then review repository status/diff to ensure only the intended production file changed and no temporary artifacts remain.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.