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/unreachable-branch implementation and relevant tests, then reproduce the reported output before making a narrowly scoped source change.

  3. Assistant

    rg is unavailable, so I’ll use grep/find to locate the analyzer and tests without installing unnecessary tooling.

  4. Assistant

    The initial search confirms a Go service around Python analysis. I’ll now inspect the Python bridge and dead-code service files, plus test names, to identify where CFG node types and source locations are transformed into findings.

  5. Assistant

    I found the core implementation in internal/analyzer/dead_code.go. I’ll read it alongside the CFG node definition and parser/builder logic to determine how a trailing semicolon is represented and where filtering is safest.

  6. Assistant

    The detector currently treats any block with at least one parser node as reportable. The issue likely arises because tree-sitter emits an unnamed ; node that the CFG builder adds as a statement. I’ll inspect parser node fields, statement traversal, and code/location extraction, then run the CLI repro to verify the exact internal behavior.

  7. Assistant

    I’ll inspect the AST type constants and CFG builder’s generic statement path. Then I’ll build the existing binary and run the supplied source through JSON output, preserving the report outside the repository if needed.

  8. Assistant

    The CFG’s reachability API counts blocks solely by statement slice length, so an empty/synthetic node must be excluded either before insertion or when collecting unreachable blocks. To avoid changing CFG behavior globally, I’ll identify the exact semicolon node shape from parser output and reproduce via CLI.

  9. Assistant

    The first reproduction build was blocked by an environment configuration (GOMODCACHE/GOPATH unset), not by source. I’ll inspect the parser’s fallback mapping and available Go environment/cache, then rerun with an explicit temporary GOPATH if dependencies are already cached or downloadable.

  10. Assistant

    The parser fallback confirms ; becomes a generic node with type ";" and zero-based tree-sitter point coordinates. I’ll rerun the supplied repro with GOPATH=/root/go, then inspect AST/body and CFG blocks using a temporary in-repository diagnostic Go test (removed afterward) if CLI output alone is insufficient.

  11. Assistant

    Go also requires a build cache because HOME is unset. I’ll provide explicit /tmp build-cache paths and rerun; this changes no repository files.

  12. Assistant

    The repro succeeded: the CLI reports exactly two warning dead-code issues (its nonzero exit is expected when findings exist) and writes JSON to its report path rather than stdout. I’ll extract those findings, then choose a source-level predicate for non-actionable empty statement nodes. Since adding tests is prohibited, I’ll validate with temporary diagnostics and existing suites only.

  13. Assistant

    The existing code already defines the semicolon representation explicitly in raw metrics. I’ll inspect that helper and nearby conventions, plus dead-code tests, to decide whether to centralize the predicate in parser/analyzer code or add a detector-local filter with minimal API impact.

  14. Assistant

    A detector-local filter is the safest scope: explicit pass remains a real source statement, while tree-sitter’s generic ";" token is only a separator. I’ll make reportability statement-aware so that (1) semicolon-only unreachable blocks create no finding or dead-block count, and (2) mixed blocks such as return; x = 1 still report x = ... with its real location/code rather than including the separator. This avoids mutating the CFG or changing unrelated raw-metric behavior.

  15. Assistant

    The implementation now filters separator nodes consistently from block eligibility, location, and rendered code. I’ll rebuild and rerun the exact supplied repro; success means the dead-code count is zero and no code: ";" finding exists. I’ll also run a temporary mixed same-line case to ensure genuine unreachable code after a semicolon remains detected.

  16. Assistant

    The exact repro is fixed: exit status is now 0, summary count is 0, and there are no dead-code files/findings. The mixed case correctly keeps the real unreachable assignment and omits ; from its code. Columns for real findings are independently zero in this architecture, but the reported impossible semicolon location is eliminated as requested.

    Next I’ll run the focused analyzer tests (including race-free standard package tests), then the broader Go test suite to catch service/summary assumptions about dead-block counts.

  17. Assistant

    Focused tests all pass. One consistency edge remains: DeadCodeDetector.HasDeadCode() currently bypasses Detect() and asks raw reachability whether any node exists, so it would still return true for a semicolon-only block even though no finding is emitted. I’ll inspect its usages/tests and, if safe, align it with filtered detector results before running the full suite.

  18. Assistant

    HasDeadCode has no external in-repo callers and should reflect detector findings rather than lower-level CFG occupancy. I’ll align it by using Detect().DeadBlocks, ensuring all public detector APIs agree that a trailing separator is not dead code.

  19. Assistant

    The API is now internally consistent, formatting and diff checks pass. I’ll run go test ./... as the complete existing Go suite, then rerun the exact CLI reproduction once more against the final source and inspect repository status for accidental artifacts.

  20. Assistant

    The complete Go suite passes across all packages. For final verification I’ll rebuild from the final source, rerun the exact two-function repro, and check that explicit pass after return; remains reportable (confirming the filter targets only synthetic separators, not user-authored statements). Then I’ll review the final diff/status.

  21. Assistant

    Final review is clean: only internal/analyzer/dead_code.go changed, git diff --check passes, the exact repro produces zero findings, mixed genuine dead code remains detected, and explicit pass behavior is unchanged.

    Checklist:

    • Successfully reproduced the reported error. Before the fix, the supplied semi_repro.py produced two unreachable_branch warnings with code: ";", for f and g.
    • Confirmed the fix resolves the error. After the final rebuild, the exact repro exits successfully with dead_code_count: 0 and no dead-code files/findings.
    • Considered edge cases. A mixed return; x = 1 still reports the unreachable assignment while excluding the separator; a user-authored return; pass still reports pass. Detector counts, rendered code, source lines, and HasDeadCode() all use the filtered semantics.
    • Ran affected existing tests. The focused analyzer/service/app/domain/integration/CLI/MCP tests passed, followed by the complete go test ./... -count=1 suite with all packages passing.

    I’ll now submit the verified change.

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