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
Let me explore the repository structure to understand the codebase.
Assistant
Let me look at the CFG builder and how statements are added, particularly empty statements from trailing semicolons.
Assistant
Let me look at the
processStatementfunction and the parser to understand how empty statements from trailing semicolons are represented.Assistant
Now let me look at the parser to understand how empty statements from trailing semicolons are represented. Let me look at how a trailing semicolon produces an empty statement.
Assistant
Let me check the ast_builder.go around the NodeExpr building to see how a trailing semicolon produces an empty statement. Let me look at lines around 798.
Assistant
Let me write a reproduction script to confirm the issue.
Assistant
The findings exist in the JSON. Let me look at the JSON structure to find them.
Assistant
I've reproduced the issue. Now let me understand how the empty statement node is structured. Let me check what the node looks like.
Assistant
The empty statement node has
Type == ";"(the literal semicolon). Let me check howbuildNodehandles this.Assistant
Let me look at the reachability analyzer to understand how unreachable blocks are collected.
Assistant
Let me check
BasicBlock.IsEmptyand theBlockdefinition.Assistant
Let me check usages of
GetUnreachableBlocksWithStatementsand howDeadBlocksis computed.Assistant
Let me look at existing dead code tests to understand expected behavior.
Assistant
Let me look at the test infrastructure to understand the expectedDead counting. Let me look at the test function.
Assistant
Let me look at the test that counts findings (the one with expectedDead counts).
Assistant
Let me check the rest of
processStatement(the default case) to understand how;nodes are handled.Assistant
Let me check how the column is computed in the service layer (the JSON shows start_column 0).
Assistant
I see - the
DeadCodeLocationonly has StartLine/EndLine (no columns). The JSON output shows start_column 0/end_column 0 — those must be zero-valued fields in the JSON because the DeadCodeLocation doesn't have column fields, but the JSON shows them. Wait, let me re-check the JSON output. The finding JSON had:code"location": {"file_path": "semi_repro.py", "start_line": 3, "end_line": 3, "start_column": 0, "end_column": 0}So DeadCodeLocation must have start_column/end_column fields. Let me check.
Assistant
Now I have a full understanding. Let me implement the fix in
dead_code.go. I'll add helpers to detect empty statements and filter them out during dead-code finding collection.Assistant
Now let me add the helper functions. Let me add them near the other helper methods.
Assistant
Now let me also filter empty statements out of
getBlockCodeso mixed blocks don't include;in the code field.Assistant
Now let me build and run the reproduction to verify the fix.
Assistant
No more
;findings — Dead Code is now 100/100 with 0 issues. Now let me run the existing tests to ensure nothing breaks.Assistant
Let me check whether there are tests involving
passafter a terminator, to decide whether filteringpasswould break anything.Assistant
Hmm, the findings output is empty for the edge repro. Let me check more carefully - maybe the findings are nested differently. Let me look at the structure. The previous repro had findings. Let me re-run and dump the dead_code findings specifically.
Assistant
No findings at all. Wait, that's odd. Let me check what the report contains. Maybe the dead_code section is empty. Let me look at the report structure.
Assistant
There's a syntax error —
;;double semicolon causes a parse error in tree-sitter. Let me fix the edge case file.Assistant
Let me check edge cases. The
gfunction correctly reports the real dead statement (assignment) with the;filtered out. Thehfunction (only;) is filtered entirely. Let me check if any tests assert onDeadBlockscount from the detector.Assistant
These construct domain models directly with hardcoded values, so they're unaffected. Let me run the broader test suite to be thorough.
Assistant
Let me check the e2e/integration tests and run them if quick.
Assistant
Let me clean up temporary files I created in the repo and check git status.
Assistant
Let me review the final diff to ensure correctness.
Assistant
Let me do a final verification with the exact repro from the issue.
Assistant
The fix is verified. Let me run the analyzer test suite one final time to confirm everything passes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.