authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-04-11 20:56:05+02:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-04-11 20:56:05+02:00
log5b584e06e37296c602357cbaf27d39e068ac98c9
tree23011765638ff8241210237b0a1775c5046da9e3
parenta7f77d7c6a4326de4c4cd356cd88e48854817e6f

std.zig.parser special cased error in return.

Related #909 This allows parsing of `std/special/build_runner.zig`

1 files changed, 20 insertions(+), 0 deletions(-)

std/zig/parser.zig+20
...@@ -2354,6 +2354,16 @@ pub const Parser = struct {...@@ -2354,6 +2354,16 @@ pub const Parser = struct {
2354 continue;2354 continue;
2355 },2355 },
2356 else => {2356 else => {
2357 // TODO: this is a special case. Remove this when #760 is fixed
2358 if (token.id == Token.Id.Keyword_error) {
2359 if (self.isPeekToken(Token.Id.LBrace)) {
2360 fn_proto.return_type = ast.NodeFnProto.ReturnType {
2361 .Explicit = &(try self.createLiteral(arena, ast.NodeErrorType, token)).base
2362 };
2363 continue;
2364 }
2365 }
2366
2357 self.putBackToken(token);2367 self.putBackToken(token);
2358 fn_proto.return_type = ast.NodeFnProto.ReturnType { .Explicit = undefined };2368 fn_proto.return_type = ast.NodeFnProto.ReturnType { .Explicit = undefined };
2359 stack.append(State {2369 stack.append(State {
...@@ -5185,3 +5195,13 @@ test "zig fmt: string identifier" {...@@ -5185,3 +5195,13 @@ test "zig fmt: string identifier" {
5185 \\5195 \\
5186 );5196 );
5187}5197}
5198
5199test "zig fmt: error return" {
5200 try testCanonical(
5201 \\fn err() error {
5202 \\ call();
5203 \\ return error.InvalidArgs;
5204 \\}
5205 \\
5206 );
5207}