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 start by exploring the repository structure and reproducing the reported dead-code false positive with trailing semicolons.
- Assistant
Let me find the dead code analyzer related files.
- Assistant
Let me look at the dead_code.go analyzer and related code.
- Assistant
Next I'll inspect finding creation and empty-statement handling in the dead-code analyzer.
- Assistant
Let me continue reading the file, particularly around detecting and converting unreachable blocks.
- Assistant
Let me continue reading and also look at NodePass and empty statement handling.
- Assistant
Let me look at getBlockCode and how nodes are represented - especially empty statements.
- Assistant
The code field is ";", so the empty statement is likely manifested as a node of that type—I'll check the parser for its node types.
- Assistant
There's no NodeEmpty or semicolon. Let me look at how statements get into the CFG when there's a semicolon.
- Assistant
There's already handling for semicolon empty statements in raw_metrics.go!
- Assistant
There's
isLogicalSeparatorthat checks for node type ";". Let me also check how Parser produces these and look at CFG builder. - Assistant
Let me see the default case in buildNode and how ";" is handled.
- Assistant
Let me look at the default case around line 191.
- Assistant
Let me look at the default case and also how statement separators are handled.
- Assistant
I'll reproduce the issue first, then implement the empty-statement filter.
- Assistant
Need to set GOPATH and GOMODCACHE.
- Assistant
Build looks good — next I'll rerun the repro case.
- Assistant
Found 2 dead code issues. Let me look at the JSON report.
- Assistant
Reproduced. Now I need to implement the fix and see how CFG handles trailing/empty statements.
- Assistant
Let me look at processStatement default case for ";" nodes.
- Assistant
Let me see the default of processStatement
- Assistant
I'll filter empty
;statements out of dead-code findings, reusing the existing separator helper. - Assistant
Implementing the filter in the dead-code analyzer.
- Assistant
The edit landed in the wrong file — I'll restore the test file and apply the change to
dead_code.go. - Assistant
Good, now I have the correct file open. Let me edit it properly.
- Assistant
I'll also fix DeadBlocks counting so empty-only blocks aren't treated as dead.
- Assistant
Rebuilding and verifying the trailing-semicolon case is fixed.
- Assistant
Fixed — 0 issues. Next I'll confirm real dead code still reports and check edge cases.
- Assistant
Something's off — real dead code should still be reported. I'll probe further.
- Assistant
Real dead code still works—I'll recheck the fuller edge-case file carefully.
- Assistant
Odd—full edge file reports 0 issues while real_dead alone finds 3. Checking the full report and errors next.
- Assistant
There's a parse error—I'll validate the edge-case file with Python's parser.
- Assistant
Confirming real dead code after a trailing semicolon still reports the assignment, not
;. - Assistant
I'll keep
getBlockCodeconsistent and run the dead-code unit tests. - Assistant
Updating
getBlockCodeso it filters empty statements for consistency. - Assistant
Checking whether
HasDeadCodeis affected. - Assistant
I'll update HasDeadCode for consistency with the empty-statement filter.
- Assistant
Running dead-code and related tests now.
- Assistant
All tests passed. Re-verifying the original repro and reviewing the final diff.
- Assistant
Checking git status before submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.