Skip to content

Commit 5f3ec02

Browse files
committed
std.zig.parser: Fixed parsing of field access rhs
related: #909
1 parent 281c17f commit 5f3ec02

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

std/zig/parser.zig

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,17 +1515,23 @@ pub const Parser = struct {
15151515
continue;
15161516
},
15171517
Token.Id.Period => {
1518+
const identifier = try self.createLiteral(arena, ast.NodeIdentifier, Token(undefined));
15181519
const node = try self.createToDestNode(arena, dest_ptr, ast.NodeInfixOp,
15191520
ast.NodeInfixOp {
15201521
.base = undefined,
15211522
.lhs = dest_ptr.get(),
15221523
.op_token = token,
15231524
.op = ast.NodeInfixOp.InfixOp.Period,
1524-
.rhs = undefined,
1525+
.rhs = &identifier.base,
15251526
}
15261527
);
15271528
stack.append(State { .SuffixOpExpressionEnd = dest_ptr }) catch unreachable;
1528-
try stack.append(State { .SuffixOpExpressionBegin = DestPtr { .Field = &node.rhs }});
1529+
try stack.append(State {
1530+
.ExpectTokenSave = ExpectTokenSave {
1531+
.id = Token.Id.Identifier,
1532+
.ptr = &identifier.token
1533+
}
1534+
});
15291535
continue;
15301536
},
15311537
else => {
@@ -5011,6 +5017,7 @@ test "zig fmt: inline asm" {
50115017
test "zig fmt: coroutines" {
50125018
try testCanonical(
50135019
\\async fn simpleAsyncFn() void {
5020+
\\ const a = async a.b();
50145021
\\ x += 1;
50155022
\\ suspend;
50165023
\\ x += 1;

0 commit comments

Comments
 (0)