Skip to content

Commit a7f77d7

Browse files
committed
std.zig.parser: requireSemiColon now matches the C++ behavior
Related #909 Allowes parsing of `std/os/child_process.zig`
1 parent df4c575 commit a7f77d7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

std/zig/parser.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,7 +2722,7 @@ pub const Parser = struct {
27222722
continue;
27232723
}
27242724

2725-
n = while_node.body;
2725+
return while_node.body.id != ast.Node.Id.Block;
27262726
},
27272727
ast.Node.Id.For => {
27282728
const for_node = @fieldParentPtr(ast.NodeFor, "base", n);
@@ -2731,7 +2731,7 @@ pub const Parser = struct {
27312731
continue;
27322732
}
27332733

2734-
n = for_node.body;
2734+
return for_node.body.id != ast.Node.Id.Block;
27352735
},
27362736
ast.Node.Id.If => {
27372737
const if_node = @fieldParentPtr(ast.NodeIf, "base", n);
@@ -2740,25 +2740,25 @@ pub const Parser = struct {
27402740
continue;
27412741
}
27422742

2743-
n = if_node.body;
2743+
return if_node.body.id != ast.Node.Id.Block;
27442744
},
27452745
ast.Node.Id.Else => {
27462746
const else_node = @fieldParentPtr(ast.NodeElse, "base", n);
27472747
n = else_node.body;
2748+
continue;
27482749
},
27492750
ast.Node.Id.Defer => {
27502751
const defer_node = @fieldParentPtr(ast.NodeDefer, "base", n);
2751-
n = defer_node.expr;
2752+
return defer_node.expr.id != ast.Node.Id.Block;
27522753
},
27532754
ast.Node.Id.Comptime => {
27542755
const comptime_node = @fieldParentPtr(ast.NodeComptime, "base", n);
2755-
n = comptime_node.expr;
2756+
return comptime_node.expr.id != ast.Node.Id.Block;
27562757
},
27572758
ast.Node.Id.Suspend => {
27582759
const suspend_node = @fieldParentPtr(ast.NodeSuspend, "base", n);
27592760
if (suspend_node.body) |body| {
2760-
n = body;
2761-
continue;
2761+
return body.id != ast.Node.Id.Block;
27622762
}
27632763

27642764
return true;

0 commit comments

Comments
 (0)