diff --git a/std/zig/parser.zig b/std/zig/parser.zig index f1f6b0e371..88e6ece35b 100644 --- a/std/zig/parser.zig +++ b/std/zig/parser.zig @@ -2354,6 +2354,16 @@ pub const Parser = struct { continue; }, else => { + // TODO: this is a special case. Remove this when #760 is fixed + if (token.id == Token.Id.Keyword_error) { + if (self.isPeekToken(Token.Id.LBrace)) { + fn_proto.return_type = ast.NodeFnProto.ReturnType { + .Explicit = &(try self.createLiteral(arena, ast.NodeErrorType, token)).base + }; + continue; + } + } + self.putBackToken(token); fn_proto.return_type = ast.NodeFnProto.ReturnType { .Explicit = undefined }; stack.append(State { @@ -5185,3 +5195,13 @@ test "zig fmt: string identifier" { \\ ); } + +test "zig fmt: error return" { + try testCanonical( + \\fn err() error { + \\ call(); + \\ return error.InvalidArgs; + \\} + \\ + ); +}