File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2354,6 +2354,16 @@ pub const Parser = struct {
2354
2354
continue ;
2355
2355
},
2356
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
2367
self .putBackToken (token );
2358
2368
fn_proto .return_type = ast.NodeFnProto.ReturnType { .Explicit = undefined };
2359
2369
stack .append (State {
@@ -5185,3 +5195,13 @@ test "zig fmt: string identifier" {
5185
5195
\\
5186
5196
);
5187
5197
}
5198
+
5199
+ test "zig fmt: error return" {
5200
+ try testCanonical (
5201
+ \\fn err() error {
5202
+ \\ call();
5203
+ \\ return error.InvalidArgs;
5204
+ \\}
5205
+ \\
5206
+ );
5207
+ }
You can’t perform that action at this time.
0 commit comments