Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/parser-native/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,17 @@ function transformExpression(node: TreeSitterNode): Expression {
case "binary_expression":
return transformBinaryExpression(node);

case "unary_expression":
// void expressions evaluate to undefined (not a unary op in our AST)
case "unary_expression": {
// Block-wrapped: parser-native's switch_case iteration drops the trailing
// return when a bare case body has [var_decl, if_no_else, return]. Wrapping
// the case in {} produces a single statement_block child that preserves all
// three statements. See #597 for the full diagnostic.
const voidOpChild = getChild(node, 0);
if (voidOpChild && (voidOpChild as NodeBase).type === "void") {
return { type: "variable", name: "undefined" };
}
return transformUnaryExpression(node);
}

case "update_expression":
return transformUpdateExpression(node);
Expand Down Expand Up @@ -1650,7 +1654,7 @@ function transformStatement(node: TreeSitterNode): Statement | null {
return transformSwitchStatement(node);

case "statement_block":
return null;
return transformStatementBlock(node);

case "empty_statement":
return null;
Expand Down
Loading