authorgravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-02-22 23:51:15+01:00
committergravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-02-22 23:51:54+01:00
log45634851de92f7848b648a0e009247e7f102e9ff
tree118d24d1208210484cee42d8c0b3362c3b8afeed
parent550688f427a2303f5e309a269def4d8be532cc54
signaturelock-open Commit is signed but in an unrecognized format.

zig fmt: fix firstToken() for extern fn_protos


2 files changed, 24 insertions(+), 23 deletions(-)

lib/std/zig/ast.zig+6-5
......@@ -366,10 +366,6 @@ pub const Tree = struct {
366366 .@"nosuspend",
367367 .asm_simple,
368368 .@"asm",
369 .fn_proto_simple,
370 .fn_proto_multi,
371 .fn_proto_one,
372 .fn_proto,
373369 .array_type,
374370 .array_type_sentinel,
375371 .error_value,
......@@ -449,7 +445,12 @@ pub const Tree = struct {
449445 .error_union,
450446 => n = datas[n].lhs,
451447
452 .fn_decl => {
448 .fn_decl,
449 .fn_proto_simple,
450 .fn_proto_multi,
451 .fn_proto_one,
452 .fn_proto,
453 => {
453454 var i = main_tokens[n]; // fn token
454455 while (i > 0) {
455456 i -= 1;
lib/std/zig/parser_test.zig+18-18
......@@ -3727,24 +3727,24 @@ test "zig fmt: Don't add extra newline after if" {
37273727 );
37283728}
37293729
3730//test "zig fmt: comments in ternary ifs" {
3731// try testCanonical(
3732// \\const x = if (true) {
3733// \\ 1;
3734// \\} else if (false)
3735// \\ // Comment
3736// \\ 0;
3737// \\const y = if (true)
3738// \\ // Comment
3739// \\ 1
3740// \\else
3741// \\ 0;
3742// \\
3743// \\pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
3744// \\
3745// );
3746//}
3747//
3730test "zig fmt: comments in ternary ifs" {
3731 try testCanonical(
3732 \\const x = if (true) {
3733 \\ 1;
3734 \\} else if (false)
3735 \\ // Comment
3736 \\ 0;
3737 \\const y = if (true)
3738 \\ // Comment
3739 \\ 1
3740 \\else
3741 \\ 0;
3742 \\
3743 \\pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
3744 \\
3745 );
3746}
3747
37483748//test "zig fmt: test comments in field access chain" {
37493749// try testCanonical(
37503750// \\pub const str = struct {