Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [BUG][auto] deadcode-trailing-semicolon-empty-stmt: trailing-semicolon…

  1. 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-severity unreachable_branch finding whose code field is a bare ; (an empty statement) whenever a return/raise statement is written with a trailing semicolon. In Python a trailing ; is a valid (if unusual) statement separator, so raise X; parses as raise X followed 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 impossible 0-0 column 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.py
    

    Actual 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 a warning-severity unreachable-code finding. The 0-0 column 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 warning that points at literal ; with a 0-0 column 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 (commit bac7f16)

    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:753 and :780).

    Interface

    No new interfaces are introduced.

    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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Claude Assistant

    Build succeeded. Let's run it to reproduce the issue.

  3. Claude Assistant

    Reproduced. Now let's find what the empty statement node type is - likely the AST produces a node with empty type or empty Location for the trailing ;.

  4. Claude Assistant

    Need to put the tool inside module or a cmd dir. Let's create it under /pyscn/cmd/debugtool temporarily.

  5. Claude Assistant

    Now update isTrivia to treat the bare ; separator token as trivia too.

  6. Claude Assistant

    Now let's rebuild and test.

  7. Claude Assistant

    dead_code_count: 0 now. Let's verify with more detail that it doesn't break other legit trailing-semicolon-with-actual-dead-code cases (e.g., real unreachable code after semicolon-separated statements like return x; y = 1).

  8. Claude Assistant

    Real dead code (after return x; y = 1) is still correctly detected (y = 1 and return y are unreachable), while the pure semicolon-only case (i) yields no false findings. This confirms the fix is well-targeted.

    Now let's clean up the temporary debug tool and run the existing test suite.

  9. Claude Assistant

    Let's run the full test suite to make sure nothing else broke.

  10. Claude Assistant

    All tests pass. Let's check git diff for the final changes and clean up temp files.

  11. Claude Assistant

    Clean, minimal diff confined to the parser's isTrivia helper. Let's clean up temporary files used for testing.

  12. Claude Assistant

    Now let's go through the checklist explicitly.

  13. Claude Assistant

    Checklist review:

    • If an error was reported in the issue description, I have successfully reproduced it. ✅ I built the pyscn binary from source, created the exact semi_repro.py from the issue, ran pyscn analyze --json --no-open, and confirmed the JSON report contained the two spurious unreachable_branch warning findings with code: ";" and start_column: 0, end_column: 0, matching the issue exactly.

    • If an error was reported in the issue description, I have confirmed that my fix resolves the error. ✅ After tracing the root cause (tree-sitter represents a trailing/inline ; as an anonymous ; token that is a direct sibling of statements inside a block/module node; the AST builder's buildBlock/buildModule were not filtering it out, so it became a synthetic statement node of type ";" that the CFG builder placed in its own basic block right after the terminating return/raise, which the reachability analyzer then flagged as an "unreachable branch"). I fixed this by extending the existing isTrivia helper (already used to filter comments/line-continuations when building statement lists) to also treat the anonymous ; token as trivia. Re-running the same repro produced dead_code_count: 0 — no findings at all for either function.

    • I have thought about edge cases and made sure my fix handles them as well. ✅ I tested:

      • A statement that has real dead code after a semicolon on the same line as a return (return x; y = 1 followed by another return y) — the fix still correctly reports y = 1 and the following return y as unreachable, showing the fix doesn't suppress genuine dead-code detection, only the meaningless bare ;.
      • A line with only semicolon-joined simple assignments and no dead code (x = 1; y = 2; z = 3) — correctly produces zero findings.
      • Verified via a debug tool that printed the tree-sitter parse tree that ; only ever appears as an anonymous statement-separator token (never as a meaningful child inside expressions, slices, argument lists, etc.), so broadening isTrivia globally is safe and doesn't risk filtering out meaningful semicolons elsewhere (Python has no other syntactic use for a bare ;).
      • The fix is general (not hardcoded to specific line/column numbers from the issue) — it addresses the root cause at the AST-building stage so it applies uniformly to any function, any nesting level, and both return;/raise;-style trailing semicolons as well as module-level trailing semicolons.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. ✅ Ran go build ./... (succeeds) and go test ./... across the entire repository (all packages report ok, including internal/parser, internal/analyzer, service, app, domain, integration, mcp, etc.), confirming no regressions.

    I also removed all temporary debug artifacts (cmd/debugtool, generated .pyscn report directories, and repro scripts) so the final diff is minimal and focused solely on the actual fix.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.