Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging 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. DeepSeek Assistant

    Let me start by understanding the repository structure and the issue. The issue is about a dead-code detector in pyscn that reports trailing semicolons as unreachable branches. Let me explore the repository first.

  3. DeepSeek Assistant

    This is a Go project (pyscn). Let me look at the structure more.

  4. DeepSeek Assistant

    Let me find the dead-code related files.

  5. DeepSeek Assistant

    Let me look at the key files. First, let me understand the dead code analyzer and the reachability analysis

  6. DeepSeek Assistant

    Now let me look at the dead_code.go file to understand how dead code findings are collected.

  7. DeepSeek Assistant

    Let me look at the BasicBlock and CFG builder to understand how empty statements are handled:

  8. DeepSeek Assistant

    Let me check the CFG and BasicBlock types

  9. DeepSeek Assistant

    Let me look at the BasicBlock and its IsEmpty method.

  10. DeepSeek Assistant

    Now let me look at the parser's node types to understand what "empty statement" looks like:

  11. DeepSeek Assistant

    Let me look at the parser's AST definitions to find what node types exist.

  12. DeepSeek Assistant

    Let me search for how semicolons are handled in the parser and AST builder.

  13. DeepSeek Assistant

    Let me look at the reachability test for empty blocks and also understand how the CFG builder processes statements - specifically how it handles separator/expression

  14. DeepSeek Assistant

    Let me look at the AST builder to understand how statements are built and how semicolons are handled:

  15. DeepSeek Assistant

    Let me look at the ast_builder.go around the expression_statement handling and around line 798.

  16. DeepSeek Assistant

    Let me look at the buildExpressionStatement function and also how suite/statement_list is processed

  17. DeepSeek Assistant

    Let me look at the buildExpressionStatement function.

  18. DeepSeek Assistant

    Let me first reproduce the issue to confirm it

  19. DeepSeek Assistant

    Now let's run pyscn on this file to reproduce the issue.

  20. DeepSeek Assistant

    Let me check the build setup.

  21. DeepSeek Assistant

    Let me check if Go is available and set up the environment.

  22. DeepSeek Assistant

    Now let's run the reproduce script:

  23. DeepSeek Assistant

    Let me check the generated JSON report.

  24. DeepSeek Assistant

    Let me understand the CFG builder's processStatement to see how expression statements are handled

  25. DeepSeek Assistant

    Let me look at the processStatement function to see how it processes different node types.

  26. DeepSeek Assistant

    Let me see the rest of the processStatement switch

  27. DeepSeek Assistant

    Let me look at the dead_code_formatter.go to see how the code field is populated from the findings.

  28. DeepSeek Assistant

    Let me look at the dead_code_usecase.go to understand how findings are mapped from analyzer to domain

  29. DeepSeek Assistant

    Let me look at the dead_code_service.go to see how findings are mapped.

  30. DeepSeek Assistant

    Let me investigate what tree-sitter creates for a trailing semicolon by writing a debug

  31. DeepSeek Assistant

    Let me put the debug script inside the repo instead

  32. DeepSeek Assistant

    Excellent! Now I can see the issue. Tree-sitter creates a node with Type=";" for the trailing semicolon. This is not any of the known node types, so getNodeDescription returns string(node.Type) = ";".

    Let me check if there's a constant for this node type in the parser:

  33. DeepSeek Assistant

    Let me look at how the ; node is built in the AST builder:

  34. DeepSeek Assistant

    Let me look at the buildNode function in ast_builder.go to understand how ; node is handled.

  35. DeepSeek Assistant

    Let me look at the buildNode function starting at line 61 to see how it handles the ; type.

  36. DeepSeek Assistant

    Let me look at the default case in buildNode.

  37. DeepSeek Assistant

    Let me look at the default case around line 191.

  38. DeepSeek Assistant

    Let me find how processStatement handles the default case / unknown node types.

  39. DeepSeek Assistant

    Let me look at all usages of IsEmpty() in the codebase to understand the impact of changing

  40. DeepSeek Assistant

    Now I have a clear understanding of the issue. The tree-sitter parser creates ; nodes (type ";") for trailing semicolons. These get added to CFG blocks, and when a block with only a ; is unreachable (after a raise/return), it gets reported as a dead code finding.

    The fix should be in BasicBlock.IsEmpty() to treat blocks with only no-op statements (like ;) as empty. This way, they'll be filtered out by GetUnreachableBlocksWithStatements().

    Let me first clean up my debug file and implement the fix:

  41. DeepSeek Assistant

    Now let me implement the fix. Let me open the cfg.go file at the IsEmpty method.

  42. DeepSeek Assistant

    Let me use the open command properly.

  43. DeepSeek Assistant

    Now let me modify the IsEmpty() method to treat ; nodes as no-op statements

  44. DeepSeek Assistant

    Let me try using replace instead.

  45. DeepSeek Assistant

    Let me use sed directly to make the change

  46. DeepSeek Assistant

    Let me verify the change was applied correctly

  47. DeepSeek Assistant

    Good, the change is applied. Now let me rebuild and test

  48. DeepSeek Assistant

    Build succeeded. Now let me test with the reproduction script.

  49. DeepSeek Assistant

    Dead Code score is now 100/100 with 0 issues. Let me verify the JSON report to confirm the findings are gone.

  50. DeepSeek Assistant

    The total findings is 0 - the fix works. Let me also run the standalone dead code analysis to verify

  51. DeepSeek Assistant

    Let me test some edge cases to make sure the fix is robust.

  52. DeepSeek Assistant

    Let me fix the test file - multiple semicolons are not valid Python

  53. DeepSeek Assistant

    1 finding - that should be the real unreachable code in f1. Let me check the JSON to confirm.

  54. DeepSeek Assistant

    The fix works correctly:

    • f1: Real unreachable code after raise is still reported (critical, line 5) ✅
    • f2, f3: Trailing semicolons after raise/return are filtered out ✅
    • f4, f5: Semicolons in normal code don't cause false positives ✅

    Now let me run the existing tests to make sure nothing is broken.

  55. DeepSeek Assistant

    All analyzer tests pass. Let me also run the service and domain tests related to dead code.

  56. DeepSeek Assistant

    Let me also run the full test suites for the relevant packages

  57. DeepSeek Assistant

    All tests pass. Let me also run the service tests.

  58. DeepSeek Assistant

    All tests pass. Let me verify the changes I've made.

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