mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
fixed IfTypeExpr parsing
This commit is contained in:
parent
e79e8993e6
commit
fa42c99d82
@ -2833,8 +2833,8 @@ fn parseIf(arena: *Allocator, it: *TokenIterator, tree: *Tree, bodyParseFn: Node
|
||||
|
||||
const else_token = eatToken(it, .Keyword_else) orelse return node;
|
||||
const payload = try parsePayload(arena, it, tree);
|
||||
const else_expr = try expectNode(arena, it, tree, parseExpr, AstError{
|
||||
.ExpectedExpr = AstError.ExpectedExpr{ .token = it.index },
|
||||
const else_expr = try expectNode(arena, it, tree, bodyParseFn, AstError{
|
||||
.InvalidToken = AstError.InvalidToken{ .token = it.index },
|
||||
});
|
||||
const else_node = try arena.create(Node.Else);
|
||||
else_node.* = Node.Else{
|
||||
|
||||
@ -2234,6 +2234,18 @@ test "zig fmt: multiline string in array" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: if type expr" {
|
||||
try testCanonical(
|
||||
\\const mycond = true;
|
||||
\\pub fn foo() if (mycond) i32 else void {
|
||||
\\ if (mycond) {
|
||||
\\ return 42;
|
||||
\\ }
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const warn = std.debug.warn;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user