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 {
13821382 else => {
13831383 self.putBackToken(token);
13841384 self.putBackToken(ctx.comptime_token);
1385 const statememt = try ctx.block.statements.addOne();
1386 stack.append(State { .Semicolon = statememt }) catch unreachable;
1387 try stack.append(State { .Expression = OptionalCtx { .Required = statememt } });
1385 const statement = try ctx.block.statements.addOne();
1386 stack.append(State { .LookForSameLineComment = statement }) catch unreachable;
1387 try stack.append(State { .Semicolon = statement });
1388 try stack.append(State { .Expression = OptionalCtx { .Required = statement } });
13881389 continue;
13891390 }
13901391 }
std/zig/parser_test.zig+8-10
......@@ -6,16 +6,14 @@
66// format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {};
77
88
9//TODO
10//test "zig fmt: same-line comptime" {
11// try testCanonical(
12// \\test "" {
13// \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
14// \\}
15// \\
16// );
17//}
18
9test "zig fmt: same-line comment on comptime expression" {
10 try testCanonical(
11 \\test "" {
12 \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
13 \\}
14 \\
15 );
16}
1917
2018test "zig fmt: float literal with exponent" {
2119 try testCanonical(