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 reproducing the reported dead-code trailing-semicolon issue.

  3. Assistant

    I'll inspect the dead-code analyzer and related internals next.

  4. Assistant

    Let me look at the dead_code.go analyzer more carefully.

  5. Assistant

    I'll read the rest of the dead-code detector, focusing on finding collection.

  6. Assistant

    Let me continue reading the analyzeDeadBlock function and related code.

  7. Assistant

    I'll check code extraction for blocks and how empty statements and unreachable blocks are identified.

  8. Assistant

    I'll inspect node descriptions and how the parser represents empty/pass statements and semicolons.

  9. Assistant

    I'll look for how empty statements and semicolon nodes are represented in the AST builder.

  10. Assistant

    I'll reproduce the issue and check how tree-sitter represents empty statements.

  11. Assistant

    Need to set up GOPATH/GOMODCACHE

  12. Assistant

    The build may still be running or completed. Let me check.

  13. Assistant

    Build succeeded; next I'll reproduce the issue with the binary.

  14. Assistant

    Confirmed two dead-code findings; inspecting the JSON report next.

  15. Assistant

    I've reproduced the bug. Next I'll inspect how the AST builder treats empty statements and unknown node types.

  16. Assistant

    I'll debug how the CFG treats semicolon nodes and check reachability filtering candidates.

  17. Assistant

    Let me find how CFGs are built in Me.

  18. Assistant

    Looking at CFG builder and how statements are processed for return. Also check isTrivia and empty_statement.

  19. Assistant

    Looking at the default case in processStatement for CFG:

  20. Assistant

    I'll run a small program to inspect how semicolon nodes appear in the AST and CFG.

  21. Assistant

    Columns are dropped in mapping; the main fix is to skip empty statements.I'll check existing dead-code tests and skip logic.

  22. Assistant

    Let me look at how domain findings are built from analyzer findings - the column issue.

  23. Assistant

    I'll check existing tests for pass/semicolon-after-return cases and how findings should behave.

  24. Assistant

    There's already a semicolon check in raw_metrics.go — I'll inspect that.

  25. Assistant

    I'll implement filtering of empty-statement blocks in the dead-code detector, then verify.

  26. Assistant

    I'll check all IsEmpty usages before deciding where to filter empty statements.

  27. Assistant

    I'll treat bare ; as empty in IsEmpty so dead-code reachability skips those no-op blocks.

  28. Assistant

    There's an extra brace from the edit — I'll remove it.

  29. Assistant

    Checking that cfg.go already imports the parser package.

  30. Assistant

    I'll consolidate the empty-statement helpers to avoid duplication.

  31. Assistant

    Need to open the file first or use sed.

  32. Assistant

    I'll update isLogicalSeparator to use isEmptyStatement

  33. Assistant

    I'll also strip empty statements from block code and line-range helpers so mixed blocks report cleanly.

  34. Assistant

    I'll armor the dead-block analyzer and have line/code helpers ignore empty statements.

  35. Assistant

    Now I'll update getBlockStartLine, getBlockEndLine, and getBlockCode to skip empty statements.

  36. Assistant

    I'll update the three helpers to skip empty statements.

  37. Assistant

    I'll check cfg_test for IsEmpty coverage, then rebuild and re-run the reproduction.

  38. Assistant

    Reproduction is clean (0 issues). Next I'll verify real dead code still reports and existing tests still pass.

  39. Assistant

    Edge cases look correct. I'll run the broader dead-code-related tests next.

  40. Assistant

    I'll review the final diff and clean up any temporary files.

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