Skip to content
TheChatArchiveThe Chat Archive
x-ai/grok-4.5· unknownHugging 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. Assistant

    I'll start by exploring the repository structure and locating the dead-code analyzer that emits unreachable findings for trailing semicolons.

  3. Assistant

    Let me search more specifically for dead code related files.

  4. Assistant

    Interesting - rg didn't find anything, maybe there's an issue with the tool. Let me try differently.

  5. Assistant

    I'll inspect the dead-code analyzer and how it maps unreachable blocks into findings.

  6. Assistant

    Let me continue reading the dead_code.go file, especially the part that converts blocks to findings.

  7. Assistant

    Let me continue reading analyzeDeadBlock and how code is extracted.

  8. Assistant

    I'll look at statement representation and how empty statements / trailing semicolons appear in the CFG.

  9. Assistant

    Next I'll check how empty/expression statements are handled and try to reproduce the bug.

  10. Assistant

    The finding's code is literally ;, so I'll track down how empty/semicolon statements are parsed into AST nodes.

  11. Assistant

    I'll inspect the AST builder's handling of unknown nodes and Keeping statements after terminators.

  12. Assistant

    Let me see the default case of buildNode

  13. Assistant

    I'll build the tool and run a minimal reproduction for trailing-semicolon dead-code findings.

  14. Assistant

    Need to set GOPATH

  15. Assistant

    Need GOCACHE and HOME too.

  16. Assistant

    Build succeeded — now I'll reproduce the trailing-semicolon findings with a synthetic file.

  17. Assistant

    Let me check the JSON report for the dead code findings.

  18. Assistant

    Confirmed. Let me look at the full finding details and then also understand what the node type is for ";".

  19. Assistant

    I'll inspect how the ";" token becomes a statement and how locations are set for those empty nodes.

  20. Assistant

    The escaping got weird with quotes. Let me be more careful.

  21. Assistant

    I'll check the existing dead-code tests and how CFG builder treats ; nodes and pass statements.

  22. Assistant

    So when there's a ";" after a raise/return, the ";" is treated as a statement added to the unreachable block.

  23. Assistant

    I'll implement filtering for empty ; statements in the dead-code path and mirror how domain findings are built.

  24. Assistant

    I'll implement empty-statement filtering in the dead-code analyzer and add a small unit test via a temp script.

  25. Assistant

    I'll update Detect and analyzeDeadBlock to ignore empty ; statements when building findings.

  26. Assistant

    I'll harden analyzeDeadBlock and teach the helpers to skip empty ; statements.

  27. Assistant

    There's leftover duplicate code from the old function — removing it next.

  28. Assistant

    Next I'll add the helper functions and update the block code/location helpers.

  29. Assistant

    I'll replace getBlockStartLine, getBlockEndLine, getBlockCode and add the helpers after analyzeDeadBlock or near getBlockCode.

  30. Assistant

    Rebuilding and verifying the reproduction is fixed.

  31. Assistant

    Dead code is clean now. I'll verify JSON output and dead-code-after-semicolon edge cases next.

  32. Assistant

    3 issues, 2 critical for mixed case. Let me see the findings.

  33. Assistant

    Mixed-case behavior looks right; next I’ll run the dead-code unit tests.

  34. Assistant

    Tests pass. Let me also run service-level dead code tests.

  35. Assistant

    All tests passed. I'll check the diff and confirm the final state of the changes.

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