diff --git a/compiler/parser/src/parser/context.rs b/compiler/parser/src/parser/context.rs index da9ade6085..3e2db39f7d 100644 --- a/compiler/parser/src/parser/context.rs +++ b/compiler/parser/src/parser/context.rs @@ -201,7 +201,7 @@ impl<'a, N: Network> ParserContext<'a, N> { } /// Parses a list of `T`s using `inner` - /// The opening and closing delimiters are `bra` and `ket`, + /// The opening and closing delimiters are specified in `delimiter`, /// and elements in the list are optionally separated by `sep`. /// When `(list, true)` is returned, `sep` was a terminator. pub(super) fn parse_list( diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index afc79846a9..1a6e4c64d9 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -296,7 +296,7 @@ impl ParserContext<'_, N> { } } - /// Returns a [`Input`] AST node if the next tokens represent a function output. + /// Returns an [`Input`] AST node if the next tokens represent a function input. fn parse_input(&mut self) -> Result { let mode = self.parse_mode()?; let name = self.expect_identifier()?; @@ -307,7 +307,7 @@ impl ParserContext<'_, N> { Ok(functions::Input { identifier: name, mode, type_, span: name.span, id: self.node_builder.next_id() }) } - /// Returns a [`Output`] AST node if the next tokens represent a function output. + /// Returns an [`Output`] AST node if the next tokens represent a function output. fn parse_output(&mut self) -> Result { let mode = self.parse_mode()?; let (type_, span) = self.parse_type()?; @@ -377,11 +377,13 @@ impl ParserContext<'_, N> { } }; - // Parse the function body. Allow empty blocks. `fn foo(a:u8);` + // Parse the function body, which must be a block, + // but we also allow no body and a semicolon instead (e.g. `fn foo(a:u8);`). let (_has_empty_block, block) = match &self.token.token { Token::LeftCurly => (false, self.parse_block()?), Token::Semicolon => { let semicolon = self.expect(&Token::Semicolon)?; + // TODO: make a distinction between empty block and no block (i.e. semicolon) (true, Block { statements: Vec::new(), span: semicolon, id: self.node_builder.next_id() }) } _ => self.unexpected("block or semicolon")?,