Skip to content

Commit

Permalink
allow functions to have empty blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-schott committed Dec 2, 2023
1 parent 94b3290 commit 20a4278
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions compiler/parser/src/parser/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl ParserContext<'_> {
};

// Parse the function body. Allow empty blocks. `fn foo(a:u8);`
let (has_empty_block, block) = match &self.token.token {
let (_has_empty_block, block) = match &self.token.token {
Token::LeftCurly => (false, self.parse_block()?),
Token::Semicolon => {
let semicolon = self.expect(&Token::Semicolon)?;
Expand All @@ -425,11 +425,6 @@ impl ParserContext<'_> {
let finalize = match self.eat(&Token::Finalize) {
false => None,
true => {
// Make sure has function body. Don't want `fn foo(); finalize foo { ... }` to be valid parsing.
if has_empty_block {
return Err(ParserError::empty_function_cannot_have_finalize(self.token.span).into());
}

// Get starting span.
let start = self.prev_token.span;

Expand Down

0 comments on commit 20a4278

Please sign in to comment.