Skip to content

Commit

Permalink
std.zig.ast: fix incorrect impl of FnProto.firstToken
Browse files Browse the repository at this point in the history
closes #1151
  • Loading branch information
andrewrk committed Jun 25, 2018
1 parent 8866bef commit 3290e72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions std/zig/ast.zig
Expand Up @@ -858,6 +858,7 @@ pub const Node = struct {

pub fn firstToken(self: *FnProto) TokenIndex {
if (self.visib_token) |visib_token| return visib_token;
if (self.async_attr) |async_attr| return async_attr.firstToken();
if (self.extern_export_inline_token) |extern_export_inline_token| return extern_export_inline_token;
assert(self.lib_name == null);
if (self.cc_token) |cc_token| return cc_token;
Expand Down
9 changes: 9 additions & 0 deletions std/zig/parser_test.zig
@@ -1,3 +1,12 @@
test "zig fmt: preserve space between async fn definitions" {
try testCanonical(
\\async fn a() void {}
\\
\\async fn b() void {}
\\
);
}

test "zig fmt: comment to disable/enable zig fmt first" {
try testCanonical(
\\// Test trailing comma syntax
Expand Down

0 comments on commit 3290e72

Please sign in to comment.