Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Untitled conversation

  1. User

    [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.

  2. Assistant

    I'll track down where unreachable-branch findings are emitted and filter out empty statements from trailing semicolons.

  3. Assistant

    Implementing the fix: filter no-op empty-statement blocks (; and pass) in the dead-code analyzer.

  4. Assistant

    Adding a test case for trailing-semicolon false positives:

  5. Assistant

    The table-driven test counts CFG-level unreachable blocks, not filtered findings — removing the misleading case.

  6. Assistant

    Fixed. Trailing semicolons after return/raise were parsed as a separate empty ; statement node in an unreachable CFG block, and the dead-code detector reported them as warning-severity unreachable_branch findings.

    Change in internal/analyzer/dead_code.go:

    • Added isNoOpStatement and blockContainsOnlyNoOpStatements to recognize no-op statements (pass and bare ; from trailing semicolons)
    • Skip those blocks when collecting findings and counting dead blocks in Detect()
    • Apply the same filter in analyzeDeadBlock() and HasDeadCode()

    Test added: TestTrailingSemicolonDeadCodeFindings covers the exact repro from the bug report (raise ...; and return y;).

    After this fix, pyscn analyze --json --no-open semi_repro.py produces no dead-code findings for trailing-semicolon-only no-ops. Real unreachable code (e.g. statements after return without a trailing ;) is still reported.

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