Skip to content

Commit

Permalink
fix(parser): Would not allow error set on arrow function
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed May 19, 2024
1 parent 1babaa6 commit f515af8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5200,7 +5200,7 @@ fn function(

const end_token: Token.Type = if (function_type.canOmitBody()) .Semicolon else .LeftBrace;

while (!self.check(end_token) and !self.check(.Eof)) {
while (!self.check(end_token) and !self.check(.Arrow) and !self.check(.Eof)) {
const error_type_node = try self.parseTypeDef(
self.ast.nodes.items(.type_def)[function_node].?.resolved_type.?.Function.generic_types,
true,
Expand All @@ -5214,7 +5214,7 @@ fn function(
self.reportError(.error_type, "Error type can't be optional");
}

if (!self.check(end_token)) {
if (!self.check(end_token) and !self.check(.Arrow)) {
try self.consume(.Comma, "Expected `,` after error type");
}
}
Expand Down

0 comments on commit f515af8

Please sign in to comment.