Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax/minimax-m3· 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).

    Interface

    No new interfaces are introduced.

    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. MiniMax Assistant

    Let me start by exploring the repository structure to understand what we're working with.

  3. MiniMax Assistant

    Let me explore the parser to understand node types and how empty statements are represented.

  4. MiniMax Assistant

    Now let me understand how an empty statement would be parsed. Let me search for "empty_statement" in the parser.

  5. MiniMax Assistant

    Now let me build the project and run the analyze command to see the actual behavior:

  6. MiniMax Assistant

    Now let me reproduce the issue:

  7. MiniMax Assistant

    Issue reproduced. Let me see the complete JSON report:

  8. MiniMax Assistant

    Let me understand how the CFG builder handles empty statements:

  9. MiniMax Assistant

    Let me create a small test to print the AST for the empty statement:

  10. MiniMax Assistant

    Now I have enough info. Let me write the test programproperly:

  11. MiniMax Assistant

    The trailing ; shows up as a node of type ; (not NodeExpr). Let me trace through to see what's happening:

  12. MiniMax Assistant

    Now I see. Tree-sitter encounters the ; as an unknown node type, so the parser creates a NodeType(";") literal. Now let me look at the cfg_builder:

  13. MiniMax Assistant

    Now I understand the flow. Let me look at the dead code analyzer more carefully and look at the relevant places to make the fix:

  14. MiniMax Assistant

    Let me examine how pass is represented in the AST:

  15. MiniMax Assistant

    Interesting! pass; produces both a Pass node AND a ; node. Let me check what the analysisdoes with this:

  16. MiniMax Assistant

    Now let me look at how the reachability analyzer finds unreachable blocks:

  17. MiniMax Assistant

    Now let me check what IsEmpty() does:

  18. MiniMax Assistant

    Let me trace what CFG gets built for the bug example:

  19. MiniMax Assistant

    Let me check how the JSON serialization handles the location:

  20. MiniMax Assistant

    Let me find where the analyzer's DeadCodeFinding gets converted to the domain's DeadCodeFinding:

  21. MiniMax Assistant

    Now I understand the full picture. Let me look at the existing analyzeDeadBlock and design the fix:

  22. MiniMax Assistant

    Now let me look at the existing test file for dead_code to understand testing conventions:

  23. MiniMax Assistant

    Let me check what happens with pass;:

  24. MiniMax Assistant

    Now I have a clear understanding. Let me implement the fix. First let me clean up the test file:

  25. MiniMax Assistant

    Now let me look at the analyzeDeadBlock function once more and design the fix:

  26. MiniMax Assistant

    Now let me implement the fix. I'll add a helper function to check if a block only contains empty/no-op statements and modify analyzeDeadBlock to skip such blocks:

  27. MiniMax Assistant

    Now let me look at how getNodeDescription handles the ; case to verify my understanding:

  28. MiniMax Assistant

    Now let me implement the fix. I'll add helper functions and modify the detect logic:

  29. MiniMax Assistant

    Now I'll implement the fix:

  30. MiniMax Assistant

    Let me use a different approach with sed and patch:

  31. MiniMax Assistant

    Now let me verify the patches were applied correctly:

  32. MiniMax Assistant

    Let me verify the file builds:

  33. MiniMax Assistant

    Now let me rebuild the binary and verify the fix:

  34. MiniMax Assistant

    Excellent! The bug is fixed. Now let me run the existing tests to ensure I haven't broken anything:

  35. MiniMax Assistant

    All existing tests pass. Now let me also test with a real file from the issue:

  36. MiniMax Assistant

    Let me test various edge cases:

  37. MiniMax Assistant

    Wait, this is strange. The output shows no files in dead_code. Let me check if maybe the test_paths arenot being detected or there's something wrong with my test file. Let me look:

  38. MiniMax Assistant

    Let me check what's happening - my test file has a syntax error. Let me simplify and try again:

  39. MiniMax Assistant

    Let me look at the test cases more carefully. The f3 case shows code: ";\nassignment" which is still showing the ;. Let me trace what happens:

  40. MiniMax Assistant

    Let me also filter empty statements from the code representation, so when a block has both ; and real dead code, the ; is not included:

  41. MiniMax Assistant

    Let me update getBlockCode to skip empty statements:

  42. MiniMax Assistant

    Now the code field for f3 is just "assignment". Let me verify the original test case:

  43. MiniMax Assistant

    The bug is fixed. Let me test the real bioconvert examples mentioned in the issue:

  44. MiniMax Assistant

    All trailing semicolons are filtered. Now let me also test that real dead code is still detected:

  45. MiniMax Assistant

    Let me run all the analyzer tests to make sure nothing is broken:

  46. MiniMax Assistant

    All dead code tests pass. Let me also run the broader analyzer tests:

  47. MiniMax Assistant

    All tests in the analyzer package pass. Let me also run the service package tests:

  48. MiniMax Assistant

    All service tests pass. Let me also test some edge cases like the issue mentioned bioconvert:

  49. MiniMax Assistant

    Let me test additional edge cases - break/continue with semicolons:

  50. MiniMax Assistant

    Excellent! All edge cases are handled. Let me view the complete diff to review the changes:

  51. MiniMax Assistant

    Let me clean up temp files and view the final state of the key parts:

  52. MiniMax Assistant

    Let me do a final comprehensive test to ensure everything works:

  53. MiniMax Assistant

    Excellent! The fix is working correctly. Let me clean up and run more tests:

  54. MiniMax Assistant

    Good. Let me also test the issue's exact reproduction case one more time to verify:

  55. MiniMax Assistant

    The fix is complete. Let me clean up and run all the analyzer tests once more:

  56. MiniMax Assistant

    All analyzer tests pass. Let me also verify the service tests:

  57. MiniMax Assistant

    All tests pass. Let me also do a final summary of what was changed:

  58. MiniMax Assistant

    Let me do one final sanity check to verify the fix works:

  59. MiniMax Assistant

    The fix works correctly. Let me also run the parser tests just to ensure no regressions:

  60. MiniMax Assistant

    All tests pass across all packages. Let me now also verify the final state of the change:

  61. MiniMax Assistant

    Only one file is modified, and the change is minimal and targeted. Let me go through the checklist:

    Checklist Review

    1. [x] If an error was reported in the issue description, I have successfully reproduced it.

      • I created /tmp/test_semi.py with the exact code from the issue and ran pyscn analyze --json --no-open. The output showed the false-positive findings with code: ";", reason: "unreachable_branch", and 0-0 column range.
    2. [x] If an error was reported in the issue description, I have confirmed that my fix resolves the error.

      • After the fix, the same /tmp/test_semi.py produces no findings (total_findings: 0).
      • The bioconvert-style examples mentioned in the issue (gff.py:618, tbl.py:114, things.py:753 and :780) all produce no findings as expected.
      • Real dead code is still detected correctly (verified with /tmp/test_real_dead.py).
    3. [x] I have thought about edge cases and made sure my fix handles them as well.

      • Edge cases tested:
        • Trailing semicolons only (filtered, no finding)
        • Trailing semicolons + real dead code (real dead code still detected, ; filtered from code field)
        • break; (filtered)
        • continue; (filtered)
        • raise ValueError(); (filtered)
        • pass; (no issue since pass isn't a terminator)
        • Bare pass (no issue since pass isn't a terminator)
        • Mixed semicolon patterns from bioconvert files (all filtered)
    4. [x] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.

      • All TestDeadCode* tests pass.
      • All internal/analyzer/ tests pass.
      • All service/ tests pass.
      • All internal/parser/ tests pass.
      • All other packages (app/, cmd/pyscn/, domain/, integration/, internal/config/, internal/mockdetector/, internal/reporter/, internal/version/, mcp/) pass.

    Summary of changes

    The fix in internal/analyzer/dead_code.go:

    1. Added isEmptyStatement(node *parser.Node) bool helper that detects no-op statements: trailing ; (tree-sitter parses as NodeType(";")), bare pass, and empty expression statements.
    2. Added hasOnlyEmptyStatements(block *BasicBlock) bool helper that checks if all statements in a block are no-ops.
    3. In Detect(): filter unreachable blocks containing only empty statements before reporting them as dead code findings, so dead_blocks count and findings stay consistent.
    4. In analyzeDeadBlock(): defensive guard that also filters blocks containing only empty statements (in case analyzeDeadBlock is called directly).
    5. In getBlockCode(): skip empty statements when building the synthesized code snippet, so a block containing both ; and real dead code reports only the real dead code (e.g., "assignment" instead of ";\nassignment").

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