std.zig.parser: Fixed parsing of field access rhs

related: #909
master
Jimmi Holst Christensen 2018-04-11 12:53:01 +02:00
parent 281c17f6ae
commit 5f3ec023cd
1 changed files with 9 additions and 2 deletions

View File

@ -1515,17 +1515,23 @@ pub const Parser = struct {
continue;
},
Token.Id.Period => {
const identifier = try self.createLiteral(arena, ast.NodeIdentifier, Token(undefined));
const node = try self.createToDestNode(arena, dest_ptr, ast.NodeInfixOp,
ast.NodeInfixOp {
.base = undefined,
.lhs = dest_ptr.get(),
.op_token = token,
.op = ast.NodeInfixOp.InfixOp.Period,
.rhs = undefined,
.rhs = &identifier.base,
}
);
stack.append(State { .SuffixOpExpressionEnd = dest_ptr }) catch unreachable;
try stack.append(State { .SuffixOpExpressionBegin = DestPtr { .Field = &node.rhs }});
try stack.append(State {
.ExpectTokenSave = ExpectTokenSave {
.id = Token.Id.Identifier,
.ptr = &identifier.token
}
});
continue;
},
else => {
@ -5011,6 +5017,7 @@ test "zig fmt: inline asm" {
test "zig fmt: coroutines" {
try testCanonical(
\\async fn simpleAsyncFn() void {
\\ const a = async a.b();
\\ x += 1;
\\ suspend;
\\ x += 1;