Skip to content

Commit eef21df

Browse files
committedMay 4, 2018
zig fmt: same-line comment on comptime expression
·
0.15.20.3.0
1 parent 8721eb6 commit eef21df

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed
 

‎std/zig/parser.zig‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
9+
test "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

2018
test "zig fmt: float literal with exponent" {
2119
try testCanonical(

0 commit comments

Comments
 (0)
Please sign in to comment.