Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging 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 start by exploring the repository structure to understand the codebase and locate the dead-code analyzer. Let's first get an overview.

  3. Assistant

    Let me explore the directory structure more to understand the project.

  4. Assistant

    This is a Go project (go.mod) with Python bindings. Let me explore the Go source code structure. The dead-code analyzer is likely in the internal directory.

  5. Assistant

    Let me explore the analyzer and parser directories:

  6. Assistant

    Let me look at the dead_code.go file since that's where the dead code analysis logic is likely to be.

  7. Assistant

    Now let me look at the reachability analyzer and the CFG structure:

  8. Assistant

    Now let me look at the CFG structure and the parser to understand how nodes are represented:

  9. Assistant

    Now let me look at the parser to understand what node types exist:

  10. Assistant

    Let me also check the test file for dead code to understand expected behavior better:

  11. Assistant

    Let me first create a reproduction script to understand the issue better:

  12. Assistant

    Let me look at how to run pyscn. Let me check if there's a binary.

  13. Assistant

    Let me check if there's already a built binary or how to build it.

  14. Assistant

    Let me check the Makefile and see how to build.

  15. Assistant

    Let me set GOPATH and GOMODCACHE and build:

  16. Assistant

    I need to set the cache directories properly.

  17. Assistant

    Good, the build succeeded. Now let me run the tool on the repro file to confirm the issue.

  18. Assistant

    Let me check the JSON report:

  19. Assistant

    I've reproduced the issue. Let me see more of the JSON:

  20. Assistant

    I've confirmed the issue. Now let me understand how the CFG builder handles statements:

  21. Assistant

    Let me look at the CFG builder code around line 363 and 384:

  22. Assistant

    The - needs to be escaped.

  23. Assistant

    Let me look at how raise is handled in the CFG builder:

  24. Assistant

    Let me see how raise is handled:

  25. Assistant

    Now let me look at the processRaiseStatement function:

  26. Assistant

    Let me look at the processRaiseStatement function:Similar to processReturnStatement:

  27. Assistant

    Let me look at the processRaiseStatement function:

  28. Assistant

    Now I understand the pattern. The processRaiseStatement (like processReturnStatement) creates an unreachable block after it. The trailing ; creates an empty statement that ends up in this unreachable block. The fix should be in the dead code detector to filter out empty/no-op statements from the findings.

    Let me understand what the empty statement looks like in the AST:

  29. Assistant

    Let me check how the parser handles trailing semicolons:

  30. Assistant

    Let me check what the AST looks like for a trailing semicolon:

  31. Assistant

    Let me look at the Node structure.

  32. Assistant

    Let me see the Node struct.

  33. Assistant

    Let me check how the parser handles empty statements by looking at the visitor:

  34. Assistant

    Let me look at how the AST builder handles the trailing semicolon and check what the AST node looks like. Let me first check the parser:

  35. Assistant

    Now I understand the issue better. The problem is that raise ValueError("nope"); is parsed as two statements: the raise and an empty statement (;). When the CFG builder processes the raise, it creates an unreachable block, and the empty statement gets added to that unreachable block.

    Let me check what the AST looks like for the empty statement:

  36. Assistant

    Let me write a quick test to see what the AST looks like for the trailing semicolon case:

  37. Assistant

    Let me create the debug file within the repository to access internal packages:

  38. Assistant

    Let me check the Location struct:

  39. Assistant

    Let me check the Location struct definition.

  40. Assistant

    Let me update the debug test with the correct field names:

  41. Assistant

    Now I can see the issue clearly. The AST parser represents the trailing ; as a separate node with type literally ;. This is a tree-sitter specific representation where raise ValueError("nope"); gets parsed as:

    1. Raise node
    2. ; node (representing the statement separator / empty statement)

    Let me check what the NodeType is for this ; node:

  42. Assistant

    The ; is not a defined NodeType. Let me check how tree-sitter represents the semicolon statement in Python.

  43. Assistant

    The ; is created directly by the tree-sitter parser. Let me look at how the AST builder creates nodes:

  44. Assistant

    Let me look at the AST builder's main buildNode function to see how unknown types are handled:

  45. Assistant

    Let me see what happens with the ; node type. Let me look at the full buildNode function:

  46. Assistant

    Now I understand the issue. The ; node falls into the default case (unhandled types) and creates a generic node with type ;. This gets added to an unreachable block after a raise/return statement.

    Let me look at the analyzeDeadBlock method more carefully and understand where to add the fix:Now I understand the issue. The ; node falls into the default case (unhandled types) and creates a generic node with type ;. Let me look at how the CFG builder handles this node:Now I understand the issue. The ; node falls into the default case and creates a generic node with type ;. This gets added to an unreachable block after the raise/return statement.

    Let me look at the analyzeDeadBlock method more carefully and understand where to add the fix:Now I understand the issue. The ; node falls into the default case (unhandled types) and creates a generic node with type ;. This gets added to an unreachable block after a raise/return statement.

    Let me look at how the CFG builder handles the ; node:

  47. Assistant

    Let me look at the switch in the processStatement function around line 476:

  48. Assistant

    Now I understand the full picture. The ; node falls into the default case of the CFG builder's processStatement and gets added to the unreachable block created after a raise or return statement.

    Let me look at how the dead code finding is created and where we should filter:Let me understand the flow. When the CFG builder processes the raise statement, it creates an unreachable block and sets b.currentBlock = unreachableBlock. Then the next statement (;) gets added to this unreachable block. The dead code detector then reports this block as dead code.

    The fix should filter out empty/no-op statements from dead code findings. Let me look at the analyzeDeadBlock method more closely and see what I need to modify.

  49. Assistant

    Now I understand the issue. Let me implement the fix. The approach is to filter out empty statements (specifically bare ; nodes) from dead code findings. When a block only contains empty statements like ;, it should not be reported as dead code.

  50. Assistant

    Now I understand the issue and the fix needed. Let me implement it. The approach is to add a helper method to check if a statement is an empty/no-op statement (like a bare ; separator), and then filter out blocks that only contain such statements when generating dead code findings.

    Let me add the filter in the analyzeDeadBlock method:

  51. Assistant

    Let me also check the Location properties for the ; node by looking at the JSON output more carefully:

  52. Assistant

    Let me find the function name for building CFGs.

  53. Assistant

    I see, it's BuildAll not BuildCFGs. Let me fix the test.

  54. Assistant

    Now I can see exactly what's happening. The ; node has Type ; and it's in the unreachable block. The fix should filter out blocks that only contain empty/no-op statements (specifically ; type nodes).

    Let me implement the fix in the analyzeDeadBlock method:

  55. Assistant

    Now I understand the issue fully. Let me implement the fix. I need to:

    1. Add a helper function to check if a statement is an empty/no-op statement (bare ;)
    2. In analyzeDeadBlock, skip blocks that only contain empty/no-op statements

    Let me add the helper function and modify analyzeDeadBlock:

  56. Assistant

    Now I need to add the blockOnlyContainsEmptyStatements helper method. Let me find a good place to add it:

  57. Assistant

    Now I need to add the blockOnlyContainsEmptyStatements helper method. Let me add it near the other helper methods:Let me add the helper method near the other block-checking helpers:

  58. Assistant

    Now I understand the full picture. Let me implement the fix. I need to:

    1. Add a helper method to check if a statement is an empty/no-op statement (bare ;)
    2. In analyzeDeadBlock, skip blocks that only contain empty/no-op statements

    Let me add the helper method:

  59. Assistant

    Now I'll implement the fix. I need to:

    1. Add a helper method to check if a block only contains empty/no-op statements
    2. Modify analyzeDeadBlock to skip such blocks

    Let me add the helper method after the blockContainsRaise method:

  60. Assistant

    Now let me make the changes. First, add the isEmptyStatement and blockOnlyContainsEmptyStatements helpers, then modify analyzeDeadBlock:

  61. Assistant

    Let me use the special edit command properly:

  62. Assistant

    The edit broke the function structure. Let me see what happened and fix it:

  63. Assistant

    The edit removed the function header. Let me restore the file and redo the edit properly:

  64. Assistant

    Now let me look at the exact line numbers of the function:

  65. Assistant

    Let me see the full function again.

  66. Assistant

    Now let me make the edit carefully, replacing the whole function:

  67. Assistant

    Wait, I need to reconsider. I should NOT include NodePass in isEmptyStatement. A pass statement is explicitly written by the developer and could be genuine dead code. The ; separator is never intentional dead code - it's just a syntactic artifact.

    Let me fix the isEmptyStatement to only check for ;:

  68. Assistant

    Now let me also update the DeadBlocks count in the Detect method to exclude blocks with only empty statements. Let me check the Detect method:

  69. Assistant

    Let me also update the DeadBlocks count to exclude blocks with only empty statements. I'll modify the Detect method to count only blocks that produce actionable findings:

  70. Assistant

    The edit broke the code. Let me restore and redo it more carefully:

  71. Assistant

    Let me look at the exact line numbers and make precise edits:

  72. Assistant

    Let me make the edits carefully, one at a time. First, let me update the Detect method:

  73. Assistant

    Good, the edit was successful. Now I need to add the helper methods blockOnlyContainsEmptyStatements and isEmptyStatement. Let me find the right place:Now I need to add the helper methods. Let me find where to add them:

  74. Assistant

    Let me look at the code around line 335:

  75. Assistant

    Now I'll add the two new helper methods after blockContainsRaise:

  76. Assistant

    The code looks good. Now I need to make sure there's a blank line between the isEmptyStatement function and the isSequentiallyAfter function. Let me fix that:

  77. Assistant

    The code looks good. Now let me test to make sure it compiles and works correctly:Now let me verify the code compiles and test it:

  78. Assistant

    Good, it compiles. Now let me rebuild the binary and test with the reproduction script:

  79. Assistant

    Good, the binary built successfully. Now let me test with the reproduction script:

  80. Assistant

    Excellent! The fix works. The dead code score is now 100/100 with 0 issues. Let me verify by checking the JSON report:

  81. Assistant

    The fix works. The dead code findings are now gone. Let me also make sure the existing tests still pass:Let me also run the existing tests to make sure nothing is broken:

  82. Assistant

    All dead code tests pass. Let me also run a broader set of tests to make sure nothing is broken:Let me run all the analyzer tests to make sure nothing is broken:

  83. Assistant

    All tests pass. Let me also run the full test suite to make sure nothing is broken:Let me run the full test suite to make sure nothing is broken:

  84. Assistant

    All tests pass. Let me also test with some edge cases to make sure the fix handles them correctly. Let me create a more comprehensive test file:

  85. Assistant

    There was a syntax error in the edge_cases.py file (the ;; double semicolon). Let me fix the test file and try again:

  86. Assistant

    Let me check the JSON report to see what findings were detected:

  87. Assistant

    The fix is working correctly:

    1. Trailing semicolons are no longer reported as dead code findings
    2. Real dead code (like x = 1 after return z in function h) is still properly detected
    3. The findings for h function correctly show code: "assignment\nassignment" for lines 14-15 (the real dead code)

    Now let me clean up the debug test files:Now let me clean up the debug test files:

  88. Assistant

    Now let me run the full test suite one more time to make sure everything is clean:

  89. Assistant

    All tests pass. Let me verify the changes I made by looking at the diff:Let me verify the changes I made by looking at the diff:

  90. Assistant

    The changes look clean and correct. Let me now go through the checklist:

    1. Reproduced the issue: Yes - confirmed 2 false positive dead code findings with code=";" and 0-0 column range when running pyscn analyze --json --no-open semi_repro.py
    2. Confirmed fix resolves the error: Yes - dead code score is now 100/100 with 0 issues after the fix
    3. Edge cases: Yes - tested with real dead code + trailing semicolons, multiple trailing semicolons, and confirmed real dead code is still properly detected
    4. Existing tests pass: Yes - all tests pass including go test ./...

    Let me also check if there are any other files that might need updating:

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