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 then find the relevant code for the dead-code analyzer. The issue is about trailing semicolons being reported as unreachable branches. I need to:

    1. Explore the repository structure
    2. Find the dead-code detection code
    3. Create a reproduction script
    4. Implement the fix
    5. Verify the fix

    Let me start by exploring the repository.

  3. DeepSeek Assistant

    This seems to be a Rust project (based on the name "pyscn" which might be a Python scanner). Let me look at the repository structure more carefully.

  4. DeepSeek Assistant

    It's a Go project. Let me look for the dead-code detection

  5. DeepSeek Assistant

    Let me look at the key files for dead-code detection and CFG building.

  6. DeepSeek Assistant

    Let me use bash_terminal to open the file.

  7. DeepSeek Assistant

    Let me scroll through the file to find where unreachable branches are detected.

  8. DeepSeek Assistant

    Let me look around line 222 where ReasonUnreachableBranch is set and the broader context of finding collection

  9. DeepSeek Assistant

    Let me look at the reachability analyzer and the GetUnreachableBlocksWithStatements

  10. DeepSeek Assistant

    Let me look at the GetUnreachableBlocksWithStatements function in reachability.go

  11. DeepSeek Assistant

    So the filtering uses block.IsEmpty(). Let me look at how BasicBlock and IsEmpty() are implemented

  12. DeepSeek Assistant

    Let me understand the parser structure for empty statements (;).

  13. DeepSeek Assistant

    Let me look at the AST node types to understand what an empty statement looks like.

  14. DeepSeek Assistant

    Let me look at the CFG builder to understand how statements are assigned to blocks, especially around returns/raises.

  15. DeepSeek Assistant

    Let me understand how empty statements from ; are represented in the AST. Let me search the parser for how semicolons are handled.

  16. DeepSeek Assistant

    Let me first create a reproduction script and run the tool to confirm the bug

  17. DeepSeek Assistant

    Now let me check if there's a binary we can run to test.

  18. DeepSeek Assistant

    Let me set up Go environment first

  19. DeepSeek Assistant

    Let me set up all the needed Go environment variables.

  20. DeepSeek Assistant

    Good, the build succeeded. Now let me run the reproduction script.

  21. DeepSeek Assistant

    Let me check the generated JSON report.

  22. DeepSeek Assistant

    I've confirmed the bug. The ; is being reported as dead code with code: ";" and 0-0 column range. Let me see the full dead code output

  23. DeepSeek Assistant

    Let me look at the full findings.

  24. DeepSeek Assistant

    Let me understand how the empty statement ; is represented in the AST. Let me write a quick test.

  25. DeepSeek Assistant

    Let me write a test within the package to understand the AST.

  26. DeepSeek Assistant

    Let me check the parser API.

  27. DeepSeek Assistant

    Let me clean up and look at how parsing works in the test files.

  28. DeepSeek Assistant

    Let me look at the existing dead_code test to understand how parsing works in tests.

  29. DeepSeek Assistant

    Let me look at the helper functions in the test.

  30. DeepSeek Assistant

    Let me see the test function body to understand how code is parsed.

  31. DeepSeek Assistant

    Let me look at how the code field is populated in analyzeDeadBlock

  32. DeepSeek Assistant

    Let me find the getBlockCode method:

  33. DeepSeek Assistant

    Let me look at these functions.

  34. DeepSeek Assistant

    Let me look at how the CFG builder processes statement lists/body.

  35. DeepSeek Assistant

    Let me look at how the CFG builder processes body/block statements.

  36. DeepSeek Assistant

    Let me look at the AST builder to understand what node ; becomes.

  37. DeepSeek Assistant

    Let me search for expression_statement handling in the AST builder

  38. DeepSeek Assistant

    Let me look at the buildExpressionStatement function.

  39. DeepSeek Assistant

    Let me look at the isTrivia function in the AST builder.

  40. DeepSeek Assistant

    Let me look at this function.

  41. DeepSeek Assistant

    Let me look at the Node structure to understand the Value field.

  42. DeepSeek Assistant

    Let me look at the Node struct.

  43. DeepSeek Assistant

    Let me look at how the code field is generated in the service layer. The ; in the output might come from a different code path.

  44. DeepSeek Assistant

    Let me search for where the analyzer's DeadCodeFinding is converted to the domain's representation.

  45. DeepSeek Assistant

    Let me write a test to dump the actual AST for understanding.

  46. DeepSeek Assistant

    Let me look at how buildNode handles unknown node types like ;.

  47. DeepSeek Assistant

    Let me look at the default case in buildNode around line 191.

  48. DeepSeek Assistant

    Let me see the default case around line 191.

  49. DeepSeek Assistant

    Now I understand the issue. The tree-sitter parser creates a node with type ";" for trailing semicolons. In the buildNode default case, this becomes a NodeType(";") node. The fix should be to return nil for ; nodes in buildNode, so they get filtered out.

    Let me implement this

  50. DeepSeek Assistant

    Now let me rebuild and test.

  51. DeepSeek Assistant

    Now let me test with the reproduction script.

  52. DeepSeek Assistant

    Let me check the raw output format.

  53. DeepSeek Assistant

    Dead code is now 100/100 with 0 issues! Let me verify the JSON report.

  54. DeepSeek Assistant

    Let me check the full dead_code section.

  55. DeepSeek Assistant

    The fix works - 0 dead code findings. Now let me run existing tests to make sure nothing is broken.

  56. DeepSeek Assistant

    Parser tests pass. Let me run the analyzer tests.

  57. DeepSeek Assistant

    All tests pass. Let me also specifically run dead code related tests.

  58. DeepSeek Assistant

    All dead code tests pass. Let me run the service and app tests as well.

  59. DeepSeek Assistant

    All tests pass! Let me clean up the debug test file.

  60. DeepSeek Assistant

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

  61. DeepSeek Assistant

    Let me check the report file path instead.

  62. DeepSeek Assistant

    Let me read the report.

  63. DeepSeek Assistant

    This is perfect! Let me verify against the original repro:

    • f1, f2: Trailing semicolons after raise/return are now filtered out (no false positives)
    • f4: Real dead code after a semicolon-terminated return is still properly detected
    • f5: pass statement after return is still detected as dead code

    Let me also verify by running the original repro exactly.

  64. DeepSeek Assistant

    The fix is confirmed working. Let me now review the changes I've made.

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