Skip to content
TheChatArchiveThe Chat Archive
gpt-5.6-sol· openaiHugging 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).

    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 first inspect the repository structure and search for the dead-code analyzer and unreachable_branch emission paths, then reproduce the reported output before making a focused source change.

  3. Assistant

    The detector is implemented in Go. I’ll inspect its collection logic, CFG node model, and relevant tests to understand how the Python parser represents the synthetic empty statement and choose the narrowest reliable filtering point.

  4. Assistant

    The reporting method currently treats any nonempty Statements slice as actionable, regardless of whether those nodes contain source code. I’ll now inspect exact node fields, CFG construction, reachability filtering, and the command/build workflow, then run the CLI against the supplied repro to observe the actual node representation indirectly or through a small diagnostic if needed.

  5. Assistant

    I’ll create the repro outside the repository (so no test files are added), build the current CLI, and inspect its JSON output. I’ll also locate parser conversion code for anonymous punctuation nodes because the expected code: ";" suggests the node type itself may be ";" with zero coordinates.

  6. Assistant

    The initial build was blocked only because this sandbox has no GOPATH/module-cache environment configured. I’ll set temporary Go cache paths and rerun. In parallel, the AST builder’s fallback at line 193 is likely where punctuation becomes a generic node, so I’ll inspect that code and the tree-sitter child traversal semantics.

  7. Assistant

    The CLI writes reports to its working directory rather than accepting --output. I’ll run it from an isolated temporary directory with only the repro file, capture the report, then inspect CFG builder statement dispatch to see why semicolon nodes become separate blocks after terminators.

  8. Assistant

    The bug reproduces exactly with two code: ";" findings. The semicolon is an anonymous tree-sitter token converted by the parser fallback into a generic NodeType(";"), and CFG construction processes it as a statement after the terminating node.

    I’ll inspect dead-code tests and statement handling in detail. The fix should filter blocks whose statements are only empty separator tokens before both counting and emitting dead code, while preserving real pass statements and mixed blocks. That avoids a “findings: 0 but dead_blocks: 1” ghost result and is narrower than suppressing all zero-width or unknown nodes.

  9. Assistant

    A block-level-only check is insufficient for return x;\nfoo(): both the synthetic separator and real unreachable code share the same block, so the report would still include ; and could use its line as the finding start. I’ll inspect all methods that iterate block statements, then introduce a single isEmptyStatement predicate and consistently exclude separators from dead-code counting, locations, and code rendering without changing CFG semantics or suppressing explicit pass.

  10. Assistant

    I’ll implement the detector-side filter now. The predicate will recognize only the parser’s anonymous ";" token (plus nil defensively), not NodePass. Detection will count/report only blocks with at least one actionable statement; code and line extraction will skip separators in mixed blocks; and HasDeadCode will use the same semantics so this repro is not considered dead code through that API either.

  11. Assistant

    The focused change is in place. I’ll rebuild and rerun the exact repro, checking not only that bare-semicolon findings disappear but that the dead-code section no longer retains ghost results. I’ll also test a mixed block (return; followed by real code) to confirm the real unreachable statement remains reported with the correct line and without ; in its code field.

  12. Assistant

    The exact repro now yields zero dead-code findings and zero dead blocks. The mixed case still reports the real print on line 3 as unreachable_after_return, and no semicolon appears in its code.

    Next I’ll run the full analyzer package tests (which cover CFG/reachability/dead-code interactions), then the repository-wide Go tests. I’ll use the temporary cache environment needed by this sandbox.

  13. Assistant

    All analyzer tests and the complete Go test suite pass. I’ll perform a final diff/status review to ensure only the intended source file changed, check formatting, and verify there are no repository artifacts from builds or repros before submitting.

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