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.
pyscn version:
v1.22.5(commitbac7f16)Found via the FP-audit skill in repo
bioconvert/bioconvert@92f4655(4 real occurrences:bioconvert/utils/biocode/gff.py:618,tbl.py:114,things.py:753and:780).ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /pyscn, current file: none) bash-$
- Assistant
I’ll first inspect the repository structure and locate the dead-code analyzer and its tests, then reproduce the semicolon finding through the project’s CLI or a focused internal API.
- Assistant
The implementation is in
internal/analyzer/dead_code.go. I’ll inspect its CFG traversal and nearby analyzer tests to understand how empty parser nodes are represented and choose the narrowest filtering point. - Assistant
The detector currently treats any unreachable block with at least one statement as reportable and renders unknown node types literally. I’ll now inspect parser node definitions, CFG statement construction, reachability filtering, and run the exact repro to identify the empty statement’s node type and metadata.
- Assistant
The CLI repro is temporarily blocked because this shell has neither
GOPATHnorGOMODCACHE; I’ll set a temporary Go cache on the next run. The parser constants suggest punctuation can become a raw node type. I’ll inspect conversion and CFG behavior first, including whether blocks could mix empty and actionable statements (important so filtering does not suppress real dead code). - Assistant
Because a basic block can contain multiple statements, filtering only whole blocks by
Code == ";"would be fragile. The robust approach is to classify and remove empty separator nodes before constructing findings, while preserving any actionable statements in a mixed block. I’ll confirm the raw AST node shape using parser APIs and inspect the exactprocessStatementtermination logic. - Assistant
I’ve confirmed that after a terminator the CFG intentionally creates an unreachable block, and the following semicolon is processed by the default branch as a statement. The cleanest upstream fix is likely to stop punctuation-only separators from entering the CFG at all; however, the issue explicitly asks filtering while collecting dead-code findings, and changing parser/CFG semantics could have broader effects. I’ll inspect AST conversion and then instrument a temporary Go program to print AST/CFG details once dependencies are available.
- Assistant
Dependency download started successfully; only
GOCACHEis also required. I’ll rerun with all cache variables, capture the exact baseline JSON, and use a temporary repository-root diagnostic program (removed afterward) to print semicolon AST and block metadata. - Assistant
The bug is reproduced: the summary reports exactly two dead-code issues for the two trailing semicolons. I’ll inspect the generated findings and diagnostic AST/CFG to establish a precise classifier rather than relying only on rendered code.
- Assistant
The diagnostic confirms the artifact is a generic parser node with
Type == ";", no body/children, and a real source span; the downstream report loses its columns elsewhere. I’ll implement narrowly in the dead-code detector: semicolon separator nodes are non-reportable, mixed blocks retain actionable statements and derive location/code only from those statements, dead-block counts reflect reportable blocks, andHasDeadCodeagrees withDetect. Explicitpasswill remain reportable because it is a real Python statement, unlike the punctuation artifact. - Assistant
The patch now filters only separator nodes and keeps detector metrics/API consistent. I’ll verify the exact CLI repro produces no dead-code findings, then run the focused analyzer tests. I’ll also use a temporary synthetic CFG check for a mixed block (
";"plus a real unreachable assignment) to ensure the real statement remains reported. - Assistant
The exact repro is fixed: dead-code score is now 100 with 0 issues, and both focused analyzer and parser suites pass. I’ll validate the mixed-block edge case and the detector’s
DeadBlocks/HasDeadCodebehavior for separator-only blocks, then inspect the diff and run the broader Go test suite. - Assistant
All validation passed, including the full repository test suite. The edge-case check confirms separator-only unreachable blocks yield zero findings/dead blocks and
HasDeadCode == false, while a mixed block still reports its real assignment at the correct line. I’ll perform one final diff/status review to ensure only the intended source file changed and no temporary diagnostics remain.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →