mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
std.zig.parser special cased error in return.
Related #909 This allows parsing of `std/special/build_runner.zig`
This commit is contained in:
parent
a7f77d7c6a
commit
5b584e06e3
@ -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;
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user