Now I understand the issue better. The dead code detector is reporting empty expression statements (from trailing semicolons) as unreachable code.
Let me trace through the code:
- When Python code like
raise ValueError("nope"); is parsed, the trailing ; creates an empty expression statement.
- The CFG builder adds this as a
NodeExpr node with no value.
- The reachability analyzer marks the block containing this empty statement as unreachable.
- The dead code detector creates a finding for this block with
Code: ";".
The fix should be in the dead code analyzer to filter out empty expression statements. Looking at the code, the best place to fix this is in analyzeDeadBlock in /pyscn/internal/analyzer/dead_code.go.
An empty expression statement is a NodeExpr with no Value and no children that represent actual content. We need to check if a block only contains such empty statements and skip those blocks.
Let me look at the analyzeDeadBlock function more carefully:
func (dcd *DeadCodeDetector) analyzeDeadBlock(block *BasicBlock) []*DeadCodeFinding {
var findings []*DeadCodeFinding
if block == nil || len(block.Statements) == 0 {
return findings
}
// Determine the reason for the dead code
reason, severity := dcd.determineDeadCodeReason(block)
// Create a finding for this dead block
finding := &DeadCodeFinding{
// ... fields set here
}
findings = append(findings, finding)
return findings
}
I need to add a check before creating the finding to see if all statements in the block are empty/no-op. An empty expression statement from a trailing ; would be a NodeExpr with no Value set.
Actually, looking at the issue description more carefully, it says:
- "Skip CFG nodes that correspond to empty statements (Python
pass-equivalent / bare ; separators) when collecting unreachable-branch findings in the dead-code analyzer."
So the fix should filter out blocks that only contain empty statements. An empty expression statement (from a trailing ;) is represented as a NodeExpr with no Value.
Let me also check the getBlockCode function to see how it extracts the code:
func (dcd *DeadCodeDetector) getBlockCode(block *BasicBlock) string {
if block == nil || len(block.Statements) == 0 {
return ""
}
var codes []string
for _, stmt := range block.Statements {
nodeDesc := dcd.getNodeDescription(stmt)
codes = append(codes, strings.TrimSpace(nodeDesc))
}
return strings.Join(codes, "\n")
}
And getNodeDescription:
func (dcd *DeadCodeDetector) getNodeDescription(node *parser.Node) string {
if node == nil {
return ""
}
switch node.Type {
case parser.NodeReturn:
return "return"
// ... other cases
case parser.NodeExpr:
return "expression"
// ...
default:
return string(node.Type)
}
}
Hmm, but the issue says the code field is ";", not "expression". Let me check how NodeExpr is handled more carefully.
Looking at the issue output:
{"function_name": "f", "location": {"start_line": 3, "start_column": 0, "end_column": 0}, "code": ";", "reason": "unreachable_branch", "severity": "warning"}
The code is ";". This means the code extraction is getting the literal semicolon character. This must be coming from the original source code at that location.
Wait, looking at getNodeDescription again, for NodeExpr it returns "expression", not ";". So the ";" must be coming from somewhere else.
Let me look at how the code field is set in the finding. In analyzeDeadBlock:
Code: dcd.getBlockCode(block),
And in getBlockCode, it uses getNodeDescription. But wait, the output shows ";" which is the literal semicolon. Let me check if there's another code extraction path.
Actually, let me re-read the issue more carefully. The issue says:
- "the finding points at literal
; with an impossible 0-0 column range"
And looking at the JSON output:
"location": {
"start_line": 3,
"start_column": 0,
"end_column": 0
},
"code": ";",
The columns are 0-0, which is the problematic part mentioned in the issue. The code field being ";" is also problematic.
Let me trace through the code path. The getBlockCode function calls getNodeDescription for each statement. For a NodeExpr, it would return "expression". But the issue says ";".
Let me check if the semicolon is being stored somewhere. Maybe the tree-sitter node for the empty expression statement has the semicolon as part of its source location.
Actually, looking at the output more carefully, I think the ";" might be coming from the getNodeDescription function. Let me check what string(node.Type) would return for an empty expression statement.
Wait, I think I need to look at how the parser creates the node for the trailing semicolon. Let me check the buildExpressionStatement function again:
func (b *ASTBuilder) buildExpressionStatement(tsNode *sitter.Node) *Node {
childCount := int(tsNode.ChildCount())
for i := 0; i < childCount; i++ {
child := tsNode.Child(i)
if child != nil && !b.isTrivia(child) {
return b.buildNode(child)
}
}
node := NewNode(NodeExpr)
node.Location = b.getLocation(tsNode)
return node
}
When there are no children (just a semicolon), it creates a NodeExpr with no value. Then in getNodeDescription:
case parser.NodeExpr:
return "expression"
This would return "expression", not ";". So the ";" must be coming from somewhere else.
Let me look at the full getNodeDescription function to see all cases.
Actually, wait. Let me look at the issue description again. It says:
"code": ";"
But looking at the getNodeDescription function, NodeExpr returns "expression". So maybe there's a different code path that produces ";".
Actually, looking at the default case in getNodeDescription:
default:
return string(node.Type)
If the node type is something like semicolon or similar, it would return that string. But the buildExpressionStatement function creates a Node(NodeExpr), which would match the NodeExpr case and return "expression".
Hmm, let me look at the actual output path more carefully. The JSON output shows "code": ";", which means the Code field of the DeadCodeFinding is ";". This comes from getBlockCode, which uses getNodeDescription.
Wait, I just realized - maybe the node type is not Expr but something else. Let me check what node type is created for an empty expression statement in tree-sitter.
Actually, let me just focus on fixing the issue. The fix should be to filter out empty statement blocks from the dead code findings. An empty statement is:
- A
NodeExpr with no Value and no children (from a trailing ;)
- Or any other node that represents a no-op
The simplest fix is to check in analyzeDeadBlock if all statements in the block are empty/no-op statements, and if so, skip creating a finding.
Let me implement the fix:
- Add a helper function to check if a statement is an empty/no-op statement
- Add a check in
analyzeDeadBlock to skip blocks that only contain empty statements
An empty expression statement would be a NodeExpr with no Value. But we should also consider:
NodePass is explicitly a pass statement, but it's also a no-op (though it's explicitly written, not implicit)
- Empty expression statements from trailing semicolons are
NodeExpr with no Value
Actually, thinking about it more, the issue is specifically about trailing semicolons. A trailing semicolon creates an empty expression statement. This is different from a pass statement.
The fix should check if a statement is an empty expression statement (from a trailing ;). This is a NodeExpr with no Value and no Name.
But wait, how do we get the ";" as the code? Let me think about this differently.
Looking at the getNodeDescription function, it returns ";" for some node type. Let me check if there's a NodeSemicolon or similar.
Actually, let me just look at the code more carefully. The default case returns string(node.Type). If the node type is semicolon, it would return "semicolon", not ";".
Hmm, let me trace through the code path again. The code field is ";", which is a single character. This could be coming from:
- The
getNodeDescription function returning ";"
- The
blockCode function using the original source code
Let me look at the getBlockCode function again. It iterates over block.Statements and calls getNodeDescription for each one. The getNodeDescription function returns various strings depending on the node type.
Wait, I think I need to look at the actual node type that's created for the empty expression statement. Let me check what tree-sitter reports for an empty expression statement.
Actually, I think the key insight is that the code field being ";" is a symptom of the bug, not the root cause. The root cause is that empty expression statements are being reported as dead code. The fix should be to filter them out, regardless of how the code field is extracted.
Let me implement the fix. The approach is:
- Add a helper function to check if a statement is an empty/no-op statement
- Add a check in
analyzeDeadBlock to skip blocks that only contain empty statements
For step 1, an empty expression statement is:
- A
NodeExpr with no Value and no Name and no children
Actually, let me look at how getNodeDescription works for different cases. For NodeExpr, it returns "expression". But the issue output shows ";". So either:
- The node type is not
Expr but something else
- The
code field is being set from a different source
Let me search for where the code field could be set to ";".
Actually, looking at the issue description again, it says:
"code": ";"
And the location is start_column: 0, end_column: 0. This is because the empty expression statement has a location that spans the semicolon character, which has no meaningful column range.
OK, I think I'm overthinking this. Let me just focus on the fix:
- Filter out blocks that only contain empty statements (from trailing semicolons)
- An empty statement is a
NodeExpr with no Value
Actually, looking at the getNodeDescription function again, I see that NodeExpr returns "expression", not ";". So the ";" must be coming from the default case: string(node.Type).
Wait, let me check what node type is created for an empty expression statement. Looking at buildExpressionStatement:
func (b *ASTBuilder) buildExpressionStatement(tsNode *sitter.Node) *Node {
childCount := int(tsNode.ChildCount())
for i := 0; i < childCount; i++ {
child := tsNode.Child(i)
if child != nil && !b.isTrivia(child) {
return b.buildNode(child)
}
}
node := NewNode(NodeExpr)
node.Location = b.getLocation(tsNode)
return node
}
If there are no children (just a semicolon), it creates Node(NodeExpr). So the node type is Expr, and getNodeDescription would return "expression".
But the issue output shows ";". This is confusing. Let me check if there's a different code path.
Actually, wait. Let me look at the getNodeDescription function more carefully:
func (dcd *DeadCodeDetector) getNodeDescription(node *parser.Node) string {
if node == nil {
return ""
}
switch node.Type {
case parser.NodeReturn:
return "return"
case parser.NodeBreak:
return "break"
// ... other cases
case parser.NodeExpr:
return "expression"
// ...
default:
return string(node.Type)
}
}
For NodeExpr, it returns "expression". But the issue output shows ";". So either:
- The node type is not
Expr
- There's a different code path
Let me check the issue description again. The code field is ";". This is a semicolon character. Maybe the tree-sitter node type is semicolon or similar, and the default case returns string(node.Type) which would be "semicolon", not ";".
Hmm, unless the node type is literally ;. Let me check if tree-sitter has a node type for semicolons.
Actually, I think the issue is that when a trailing ; is encountered, tree-sitter creates a node with type ; or similar. And the buildExpressionStatement function would then return the first child, which might be the semicolon node itself.
Wait, let me re-read buildExpressionStatement:
func (b *ASTBuilder) buildExpressionStatement(tsNode *sitter.Node) *Node {
childCount := int(tsNode.ChildCount())
for i := 0; i < childCount; i++ {
child := tsNode.Child(i)
if child != nil && !b.isTrivia(child) {
return b.buildNode(child)
}
}
node := NewNode(NodeExpr)
node.Location = b.getLocation(tsNode)
return node
}
If there's a child that's not trivia (like a semicolon), it would call buildNode(child). If the semicolon is a child, buildNode would fall through to the default case and create a node with type ;.
But wait, tree-sitter might not have a node type for semicolons. Semicolons are usually considered trivia or separators.
Actually, let me just focus on the fix. The issue is that empty expression statements are being reported as dead code. The fix is to filter them out.
Looking at the getNodeDescription function, I see that NodeExpr returns "expression". But the issue output shows ";". This means the node type must be something other than Expr.
Let me check what happens when tree-sitter parses raise ValueError("nope");. The trailing ; might create a node with type ; or similar.
OK, I think I need to just look at the actual behavior. Let me check if there's a way to debug the CFG construction.
Actually, let me just implement the fix. The approach is:
- Add a helper function to check if a statement is an empty statement (no-op)
- Add a check in
analyzeDeadBlock to skip blocks that only contain empty statements
For step 1, an empty statement is a node that has no meaningful content. This includes:
- A
NodeExpr with no Value (empty expression statement)
- Any node where
string(node.Type) is ";" (if that's the case)
Actually, the simplest approach is to check if the node description is empty or consists only of a semicolon.
Wait, let me re-read the getNodeDescription function:
case parser.NodeExpr:
return "expression"
This returns "expression", not ";". So the node type must be something else.
Let me check if there's a node type for empty statements. Looking at the parser/ast.go file:
const (
// ... other node types
NodeExpr NodeType = "Expr"
// ...
)
There's no NodeEmptyStmt or similar. So when tree-sitter creates a node for the trailing ;, it must create a node with a type that's not in the switch statement.
Actually, let me check if the semicolon is a child of the expression statement node. If so, buildExpressionStatement would call buildNode(child) for the semicolon. And buildNode might not have a case for semicolons, so it would fall through to the default case.
Let me check the buildNode function:
func (b *ASTBuilder) buildNode(tsNode *sitter.Node) *Node {
if tsNode == nil {
return nil
}
nodeType := tsNode.Type()
switch nodeType {
// ... many cases
// No case for ";"
default:
return b.buildDefaultNode(tsNode)
}
}
And buildDefaultNode might create a node with the type being the string of the tree-sitter node type.
OK, I think the issue is that tree-sitter creates a node with type ; (or similar) for the trailing semicolon, and this node is added to the CFG as a statement. The getNodeDescription function then returns string(node.Type) which is ";".
So the fix is to check if a node represents an empty statement (a semicolon with no expression). This could be done by checking if:
- The node type is
; or similar
- Or the node is an expression statement with no meaningful content
Actually, the simplest approach is to check if the node description (from getNodeDescription) is empty or consists only of a semicolon.
Let me implement the fix:
- In
analyzeDeadBlock, check if all statements in the block are empty statements
- If so, skip creating a finding for the block
An empty statement is:
- A node where
getNodeDescription returns ";" or is empty
- Or a
NodeExpr with no Value
Actually, let me think about this more carefully. The issue says:
- "Skip CFG nodes that correspond to empty statements (Python
pass-equivalent / bare ; separators) when collecting unreachable-branch findings in the dead-code analyzer."
So the fix should filter out nodes that represent empty statements. An empty statement is:
- A
NodeExpr with no Value (from a trailing ;)
- A node with type
; (if that's the case)
The simplest fix is to check if all statements in a block are empty, and if so, skip creating a finding.
Let me implement this:
// isEmptyStatement checks if a statement is an empty/no-op statement
// that should not be reported as dead code
func (dcd *DeadCodeDetector) isEmptyStatement(stmt *parser.Node) bool {
if stmt == nil {
return true
}
// Empty expression statement (from trailing ;): NodeExpr with no value
if stmt.Type == parser.NodeExpr && stmt.Value == nil {
return true
}
// Empty statement with semicolon as type
if string(stmt.Type) == ";" {
return true
}
return false
}
And then in analyzeDeadBlock:
func (dcd *DeadCodeDetector) analyzeDeadBlock(block *BasicBlock) []*DeadCodeFinding {
var findings []*DeadCodeFinding
if block == nil || len(block.Statements) == 0 {
return findings
}
// Check if all statements in the block are empty/no-op
allEmpty := true
for _, stmt := range block.Statements {
if !dcd.isEmptyStatement(stmt) {
allEmpty = false
break
}
}
// Skip blocks that only contain empty statements
if allEmpty {
return findings
}
// ... rest of the function
}
This should filter out blocks that only contain empty expression statements from trailing semicolons.
Actually, wait. Let me re-read the issue. It says the code field is ";". And looking at the getNodeDescription function, the default case returns string(node.Type). So the node type must be ;.
But looking at buildExpressionStatement:
func (b *ASTBuilder) buildExpressionStatement(tsNode *sitter.Node) *Node {
childCount := int(tsNode.ChildCount())
for i := 0; i < childCount; i++ {
child := tsNode.Child(i)
if child != nil && !b.isTrivia(child) {
return b.buildNode(child)
}
}
node := NewNode(NodeExpr)
node.Location = b.getLocation(tsNode)
return node
}
If there's a child that's not trivia, it calls buildNode(child). If the child is a semicolon, buildNode would create a node with type ;.
But wait, I'm not sure if tree-sitter creates a separate node for the semicolon. Let me check.
Actually, I think the issue is that when tree-sitter parses raise ValueError("nope");, it creates:
- A
raise_statement node for raise ValueError("nope")
- An
expression_statement node for the trailing ;
The expression_statement node has no children (just the semicolon), so buildExpressionStatement creates a NodeExpr with no value.
But then getNodeDescription for NodeExpr returns "expression", not ";". So the ";" must be coming from somewhere else.
Let me look at the issue output again:
"code": ";"
And looking at the getBlockCode function:
func (dcd *DeadCodeDetector) getBlockCode(block *BasicBlock) string {
if block == nil || len(block.Statements) == 0 {
return ""
}
var codes []string
for _, stmt := range block.Statements {
nodeDesc := dcd.getNodeDescription(stmt)
codes = append(codes, strings.TrimSpace(nodeDesc))
}
return strings.Join(codes, "\n")
}
This calls getNodeDescription for each statement and joins them. If there's only one statement (the empty expression), codes would be ["expression"] and the result would be "expression".
But the issue output shows ";". So either:
- The node type is not
Expr
- The
code field is being set from a different source
Let me search for where else the code field could be set.
Actually, looking at the domain layer:
// DeadCodeFinding represents a single dead code detection result
type DeadCodeFinding struct {
// ...
Code string `json:"code"`
// ...
}
And in the service layer:
func (s *DeadCodeServiceImpl) convertToFunctionDeadCode(result *analyzer.DeadCodeResult, req domain.DeadCodeRequest) domain.FunctionDeadCode {
var findings []domain.DeadCodeFinding
for _, analyzerFinding := range result.Findings {
finding := domain.DeadCodeFinding{
// ...
Code: analyzerFinding.Code,
// ...
}
findings = append(findings, finding)
}
functionResult := domain.FunctionDeadCode{
// ...
}
return functionResult
}
So the Code field is copied from the analyzer finding. And the analyzer finding's Code field comes from getBlockCode, which uses getNodeDescription.
OK, I'm going in circles. Let me just implement the fix and test it. The fix is to filter out empty statements from dead code findings.
Actually, wait. Let me check if there's a different code path that produces ";". Let me look at the full getNodeDescription function:
func (dcd *DeadCodeDetector) getNodeDescription(node *parser.Node) string {
if node == nil {
return ""
}
switch node.Type {
case parser.NodeReturn:
return "return"
case parser.NodeBreak:
return "break"
case parser.NodeContinue:
return "continue"
case parser.NodeRaise:
return "raise"
case parser.NodeAssign:
if node.Name != "" {
return node.Name + " = ..."
}
return "assignment"
case parser.NodeExpr:
return "expression"
case parser.NodeIf:
return "if"
case parser.NodeFor:
return "for"
case parser.NodeWhile:
return "while"
case parser.NodeTry:
return "try"
case parser.NodePass:
return "pass"
default:
return string(node.Type)
}
}
The default case returns string(node.Type). If the node type is ;, it would return ";". So the node type must be ;.
This means the tree-sitter node for the trailing ; has type ;. And buildExpressionStatement is returning this node as-is (by calling buildNode(child) for the semicolon child).
Wait, let me re-read buildExpressionStatement:
func (b *ASTBuilder) buildExpressionStatement(tsNode *sitter.Node) *Node {
childCount := int(tsNode.ChildCount())
for i := 0; i < childCount; i++ {
child := tsNode.Child(i)
if child != nil && !b.isTrivia(child) {
return b.buildNode(child)
}
}
node := NewNode(NodeExpr)
node.Location = b.getLocation(tsNode)
return node
}
If the expression statement has a child that's not trivia (like a semicolon), it calls buildNode(child). If the child is a semicolon node with type ;, buildNode would call buildDefaultNode, which would create a node with type ;.
OK, so the node type is ;, and getNodeDescription returns ";". This matches the issue output.
So the fix should check for nodes with type ; and filter them out. Additionally, we should also check for NodeExpr with no value, as that might also represent an empty expression statement.
Let me implement the fix:
// isEmptyStatement checks if a statement is an empty/no-op statement
// that should not be reported as dead code
func (dcd *DeadCodeDetector) isEmptyStatement(stmt *parser.Node) bool {
if stmt == nil {
return true
}
// Empty expression statement (from trailing ;): NodeExpr with no value
if stmt.Type == parser.NodeExpr && stmt.Value == nil && len(stmt.Children) == 0 {
return true
}
// Empty statement with semicolon as type
if string(stmt.Type) == ";" {
return true
}
return false
}
Actually, wait. Looking at the issue more carefully, I think the node type is ;. But I should also handle NodeExpr with no value, as that might also represent an empty expression statement in some cases.
Let me also check if NodePass should be filtered out. A pass statement is explicitly written and is a no-op, but it's not the same as an empty expression statement from a trailing ;. The issue says to filter out "Python pass-equivalent / bare ; separators". So maybe pass should also be filtered out.
But actually, pass is an explicit statement and might be intentional. The issue is specifically about trailing semicolons, which are unintentional no-ops. So I think we should only filter out:
- Nodes with type
;
NodeExpr with no value
Actually, let me re-read the issue description:
- "Skip CFG nodes that correspond to empty statements (Python
pass-equivalent / bare ; separators)"
This suggests filtering out pass statements as well. But I think pass is explicitly written and might be intentional, so it's different from a trailing ;.
Actually, looking at the issue description again:
- "the gist isn't wrong (the
; truly follows a terminating statement), but the output is misleading"
So the issue is specifically about trailing ;. A pass statement is explicitly written and might be intentional, so it's not the same as a trailing ;.
Let me just focus on filtering out:
- Nodes with type
;
NodeExpr with no value (from trailing ; when tree-sitter creates a NodeExpr instead of a node with type ;)
Actually, I realize I might be overthinking this. Let me just implement the fix and test it. The fix is to filter out blocks that only contain empty statements.
Hmm, actually let me reconsider. Let me trace through the code path more carefully.
When Python code like raise ValueError("nope"); is parsed by tree-sitter, what happens?
- Tree-sitter parses the code and creates a parse tree
- The parse tree has a
raise_statement node for raise ValueError("nope") and an expression_statement node for the trailing ;
- The
expression_statement node might have a child that's a semicolon (type ;)
buildExpressionStatement calls buildNode(child) for the semicolon child
buildNode falls through to buildDefaultNode, which creates a node with type ;
Or:
4. The expression_statement node has no children (the semicolon is part of the statement syntax)
5. buildExpressionStatement creates a NodeExpr with no value
I'm not sure which one is correct. Let me just implement the fix to handle both cases.
Actually, looking at the issue output again:
"code": ";"
This matches the default case in getNodeDescription: return string(node.Type). So the node type must be ;.
This means the tree-sitter node for the trailing ; has type ;, and buildNode creates a node with type ;.
But wait, let me check buildDefaultNode:
func (b *ASTBuilder) buildDefaultNode(tsNode *sitter.Node) *Node {
// ...
node := NewNode(NodeType(tsNode.Type()))
// ...
return node
}
Yes, this creates a node with the type being the string of the tree-sitter node type. So if the tree-sitter node type is ;, the created node would have type ;.
OK, so the fix should check for nodes with type ;. But I should also handle NodeExpr with no value, as that might also represent an empty expression statement in some cases (if tree-sitter doesn't create a separate node for the semicolon).
Let me implement the fix:
// isEmptyStatement checks if a statement is an empty/no-op statement
// that should not be reported as dead code
func (dcd *DeadCodeDetector) isEmptyStatement(stmt *parser.Node) bool {
if stmt == nil {
return true
}
// Empty expression statement (from trailing ;): NodeExpr with no value
if stmt.Type == parser.NodeExpr && stmt.Value == nil {
return true
}
// Empty statement with semicolon as type
if string(stmt.Type) == ";" {
return true
}
return false
}
And then in analyzeDeadBlock:
func (dcd *DeadCodeDetector) analyzeDeadBlock(block *BasicBlock) []*DeadCodeFinding {
var findings []*DeadCodeFinding
if block == nil || len(block.Statements) == 0 {
return findings
}
// Check if all statements in the block are empty/no-op
allEmpty := true
for _, stmt := range block.Statements {
if !dcd.isEmptyStatement(stmt) {
allEmpty = false
break
}
}
// Skip blocks that only contain empty statements
if allEmpty {
return findings
}
// Determine the reason for the dead code
reason, severity := dcd.determineDeadCodeReason(block)
// Create a finding for this dead block
finding := &DeadCodeFinding{
// ... fields set here
}
findings = append(findings, finding)
return findings
}
This should fix the issue. Let me implement it.
Wait, I should also think about edge cases:
- What if a block contains both empty statements and non-empty statements? In this case, we should still create a finding.
- What if a block contains only
pass statements? In this case, we should probably still create a finding, as pass is explicitly written.
I think my fix handles these cases correctly:
- A block with mixed empty and non-empty statements will still create a finding (because
allEmpty will be false)
- A block with only
pass statements will still create a finding (because pass is not an empty statement according to isEmptyStatement)
But wait, looking at the issue description again:
- "Skip CFG nodes that correspond to empty statements (Python
pass-equivalent / bare ; separators)"
This suggests filtering out pass as well. But I think pass is explicitly written and might be intentional. Let me re-read the issue.
Actually, looking at the issue:
- "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."
The issue is specifically about trailing ;, not about pass. A pass statement is explicitly written and might be intentional, so it's not the same as a trailing ;.
Let me just focus on filtering out trailing ; statements. These are represented as:
- Nodes with type
;
NodeExpr with no value
Actually, let me reconsider. Looking at the issue description again:
- "Skip CFG nodes that correspond to empty statements (Python
pass-equivalent / bare ; separators) when collecting unreachable-branch findings in the dead-code analyzer."
This says "Python pass-equivalent / bare ; separators". So it's suggesting to filter out both pass and ; statements.
But I think the issue is specifically about trailing ;. A pass statement is explicitly written and might be intentional, so it's not the same as a trailing ;.
Let me just focus on filtering out trailing ; statements. If the fix doesn't handle pass, it's fine because pass is explicitly written and might be intentional.
Actually, I realize I should also check if there are existing tests that I need to update. Let me look at the dead code tests.
<tool_call>
<function=bash_terminal>
<parameter=command>
cat /pyscn/internal/analyzer/dead_code_test.go | head -200
</tool_call>