Skip to content

Commit 3290e72

Browse files
committedJun 25, 2018
std.zig.ast: fix incorrect impl of FnProto.firstToken
closes #1151
·
0.15.20.3.0
1 parent 8866bef commit 3290e72

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎std/zig/ast.zig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ pub const Node = struct {
858858

859859
pub fn firstToken(self: *FnProto) TokenIndex {
860860
if (self.visib_token) |visib_token| return visib_token;
861+
if (self.async_attr) |async_attr| return async_attr.firstToken();
861862
if (self.extern_export_inline_token) |extern_export_inline_token| return extern_export_inline_token;
862863
assert(self.lib_name == null);
863864
if (self.cc_token) |cc_token| return cc_token;

‎std/zig/parser_test.zig‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
test "zig fmt: preserve space between async fn definitions" {
2+
try testCanonical(
3+
\\async fn a() void {}
4+
\\
5+
\\async fn b() void {}
6+
\\
7+
);
8+
}
9+
110
test "zig fmt: comment to disable/enable zig fmt first" {
211
try testCanonical(
312
\\// Test trailing comma syntax

0 commit comments

Comments
 (0)
Please sign in to comment.