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

    Reproduced. Let's inspect the JSON report.

  3. Claude Assistant

    Good, reproduced exactly. Now let's find where CFG builder creates blocks for statements to understand where an "empty" block with code ";" comes from.

  4. Claude Assistant

    Now let's check the default case in buildNode too, since it's a generic fallback used for arbitrary constructs (in case unnamed nodes sneak into other statement lists like if/for/try suites built differently, or decorated statements, etc.)

  5. Claude Assistant

    Good, this confirms extractBlockBody uses buildBlock's output, so fixing buildBlock covers function/if/for/while/try bodies. Now let's rebuild and test.

  6. Claude Assistant

    The finding is now gone (Dead Code 100/100, 0 issues). Let's verify the JSON directly to be thorough, and also test edge cases (semicolon-separated multiple statements, semicolons not at end, nested blocks).

  7. Claude Assistant

    Now let's test edge cases: multiple statements separated by semicolons on one line, semicolon after normal (non-terminating) statement, semicolons in nested blocks, and actual real unreachable code after a trailing-semicolon return.

  8. Claude Assistant

    Genuine unreachable code after both trailing-semicolon and normal return statements is still correctly detected (no false positive for the semicolons themselves, and no false negative for the real dead code). Now let's run the existing test suite to check for regressions.

  9. Claude Assistant

    All tests pass. Let's run the full test suite to be safe.

  10. Claude Assistant

    All tests pass. Let's clean up temp files and view the diff.

  11. Claude Assistant

    Clean. Now let me go through the checklist:

    • Reproduced the reported error: Yes — using the exact semi_repro.py from the issue, I confirmed the JSON report contained two unreachable_branch warnings with code: ";" and 0-0 column ranges before the fix.
    • Confirmed the fix resolves it: Yes — after the fix, the same file produces Dead Code: 100/100 (0 issues) and the dead_code.files array is null/empty; no more ;-coded findings.
    • Edge cases considered: Tested (a) multiple semicolon-separated statements on one line (x = a; y = b; return x + y), (b) double ;;, (c) pass; inside an if, (d) genuine unreachable code following both a normal return and a semicolon-terminated return/raise to make sure real dead-code detection still fires correctly (it does, unaffected). The root-cause fix (filtering unnamed/anonymous tree-sitter tokens like the ; separator when building block/module statement bodies) is general — it doesn't special-case the dead-code analyzer, so it also prevents any other analysis stage (CFG, complexity, clones, etc.) from ever seeing bogus empty-statement AST nodes, and it does not hardcode based on literal ; text but on the tree-sitter "named vs unnamed" node distinction, which is a general concept covering any similar stray punctuation.
    • Existing tests pass: Ran go build ./... and go test ./... for the whole repository — all packages pass (internal/parser, internal/analyzer, service, app, domain, integration, mcp, etc.), confirming no regressions.

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