Skip to content

Commit

Permalink
zig fmt: same-line comment on comptime expression
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed May 4, 2018
1 parent 8721eb6 commit eef21df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
7 changes: 4 additions & 3 deletions std/zig/parser.zig
Expand Up @@ -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;
}
}
Expand Down
18 changes: 8 additions & 10 deletions std/zig/parser_test.zig
Expand Up @@ -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(
Expand Down

0 comments on commit eef21df

Please sign in to comment.