commit eef21df94fed2b77d8ca6a459686169bb6aca57b (tree)
parent 8721eb68fc566ec5b71b3c8f90726fd815a3d45a
Author: Andrew Kelley <superjoe30@gmail.com>
Date: Fri, 4 May 2018 16:46:35 -0400
zig fmt: same-line comment on comptime expression
Diffstat:
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/std/zig/parser.zig b/std/zig/parser.zig
@@ -1382,9 +1382,10 @@ pub const Parser = struct {
else => {
self.putBackToken(token);
self.putBackToken(ctx.comptime_token);
- const statememt = try ctx.block.statements.addOne();
- stack.append(State { .Semicolon = statememt }) catch unreachable;
- try stack.append(State { .Expression = OptionalCtx { .Required = statememt } });
+ const statement = try ctx.block.statements.addOne();
+ stack.append(State { .LookForSameLineComment = statement }) catch unreachable;
+ try stack.append(State { .Semicolon = statement });
+ try stack.append(State { .Expression = OptionalCtx { .Required = statement } });
continue;
}
}
diff --git a/std/zig/parser_test.zig b/std/zig/parser_test.zig
@@ -6,16 +6,14 @@
// format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {};
-//TODO
-//test "zig fmt: same-line comptime" {
-// try testCanonical(
-// \\test "" {
-// \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
-// \\}
-// \\
-// );
-//}
-
+test "zig fmt: same-line comment on comptime expression" {
+ try testCanonical(
+ \\test "" {
+ \\ comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
+ \\}
+ \\
+ );
+}
test "zig fmt: float literal with exponent" {
try testCanonical(