authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-04 16:46:35-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-04 16:46:35-04:00
logeef21df94fed2b77d8ca6a459686169bb6aca57b
tree60852cb236de9bca2b7c8b0db4fc9186c071cbf4
parent8721eb68fc566ec5b71b3c8f90726fd815a3d45a

zig fmt: same-line comment on comptime expression


2 files changed, 12 insertions(+), 13 deletions(-)

std/zig/parser.zig+4-3
...@@ -1382,9 +1382,10 @@ pub const Parser = struct {...@@ -1382,9 +1382,10 @@ pub const Parser = struct {
1382 else => {1382 else => {
1383 self.putBackToken(token);1383 self.putBackToken(token);
1384 self.putBackToken(ctx.comptime_token);1384 self.putBackToken(ctx.comptime_token);
1385 const statememt = try ctx.block.statements.addOne();1385 const statement = try ctx.block.statements.addOne();
1386 stack.append(State { .Semicolon = statememt }) catch unreachable;1386 stack.append(State { .LookForSameLineComment = statement }) catch unreachable;
1387 try stack.append(State { .Expression = OptionalCtx { .Required = statememt } });1387 try stack.append(State { .Semicolon = statement });
1388 try stack.append(State { .Expression = OptionalCtx { .Required = statement } });
1388 continue;1389 continue;
1389 }1390 }
1390 }1391 }
std/zig/parser_test.zig+8-10
...@@ -6,16 +6,14 @@...@@ -6,16 +6,14 @@
6// format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {};6// format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {};
77
88
9//TODO9test "zig fmt: same-line comment on comptime expression" {
10//test "zig fmt: same-line comptime" {10 try testCanonical(
11// try testCanonical(11 \\test "" {
12// \\test "" {12 \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
13// \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt13 \\}
14// \\}14 \\
15// \\15 );
16// );16}
17//}
18
1917
20test "zig fmt: float literal with exponent" {18test "zig fmt: float literal with exponent" {
21 try testCanonical(19 try testCanonical(