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 so we can reproduce the trailing-semicolon false positive.

  3. Assistant

    Let me search more specifically for dead code related files.

  4. Assistant

    Hmm, rg didn't find anything. Let me look in internal/analyzer

  5. Assistant

    I'll inspect dead_code.go next to see how unreachable findings are produced.

  6. Assistant

    Let me continue reading the dead code detector logic.

  7. Assistant

    Let me continue reading analyzeDeadBlock and related functions.

  8. Assistant

    I'll check how block code is extracted and how empty statements show up in the CFG.

  9. Assistant

    Let me check getBlockCode and also searching for empty/pass statement handling.

  10. Assistant

    I'll look up how empty statements and pass nodes are modeled in the parser.

  11. Assistant

    rg is not available? Earlier it returned empty. Let me use grep.

  12. Assistant

    I'll inspect the AST builder next for how semicolon-separated statements are handled.

  13. Assistant

    I'll inspect unrecognized-node handling and CFG statement processing.

  14. Assistant

    I'll reproduce the bug and inspect the CFG empty-statement nodes.

  15. Assistant

    Need to set up Go environment.

  16. Assistant

    Seems like the build might still be running or finished without output. Let me check.

  17. Assistant

    Good, build succeeded. Let's reproduce.

  18. Assistant

    Reproduced. Let me look at the JSON findings.

  19. Assistant

    Confirmed. Let me look at the full finding structure and also understand how the CFG handles the empty statement.

  20. Assistant

    I'll dump AST/CFG nodes for a trailing-semicolon sample to confirm the empty-statement shape.

  21. Assistant

    Let me look at how CFG is built and how dead code tests work.

  22. Assistant

    Let me look at processStatement for how return/raise create successor blocks for the empty statement after semicolon, and also what seimcolon node looks like.

  23. Assistant

    Oops, wrong sed syntax.

  24. Assistant

    I'll check how statement lists and semicolon separators are parsed into the AST.

  25. Assistant

    Let me write a proper inspection program affirmatively using the test package approach, or just a unit test style script.

  26. Assistant

    Let me also look at isTrivia and what tree-sitter does with ;. The tree-sitter python grammar has ; as a statement separator, and empty statements might appear as nodes of type ;.

  27. Assistant

    Can't import internal package from outside. I'll put a test file in the analyzer package temporarily.

  28. Assistant

    I'll drop the bare ; case and re-run on valid trailing-semicolon samples.

  29. Assistant

    I'll check how findings are mapped into the domain model next.

  30. Assistant

    Let me look at the mapping in dead_code_service.go

  31. Assistant

    I'll inspect how unreachable blocks with statements are collected before implementing the filter.

  32. Assistant

    Implementing the filter in the dead-code analyzer so empty ;/pass statements don't produce findings.

  33. Assistant

    I'll apply the empty-statement filter in dead_code.go now.

  34. Assistant

    Next I'll add the statement helpers and simplify the no-op check.

  35. Assistant

    Updating block helpers to ignore no-ops and introduce statement-slice variants.

  36. Assistant

    Simplifying isNoOpStatement and verifying compilation.

  37. Assistant

    There's an extra } at line 259 — removing it.

  38. Assistant

    There's a duplicate comment line. Let me fix that.

  39. Assistant

    There's still an extra } on line 259. Let me fix it carefully.

  40. Assistant

    There's a duplicated function signature. Let me fix by removing line 262.

  41. Assistant

    File looks clean. Compiling and running the inspect test plus dead-code tests.

  42. Assistant

    Tests passed. Verifying the original repro is fixed and rechecking edge cases.

  43. Assistant

    Trailing-semicolon-only case is fixed. Checking the mixed real-dead-code cases next.

  44. Assistant

    Results look correct. Removing the temp test and running the full analyzer suite.

  45. Assistant

    All tests passed. Reviewing the final diff before submit.

  46. Assistant

    Formatting looks good. Submitting the fix.

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