(&mut self)
| 327 | } |
| 328 | Some(Token::Ident(_)) if self.peek_n(1) == Some(&Token::ColonEqual) => { |
| 329 | let name = self.expect_ident()?; |
| 330 | self.expect_colon_equal()?; |
| 331 | if matches!(self.peek(), Some(Token::Import)) { |
| 332 | return Err(self.error( |
| 333 | "`import(...)` is only valid as a top-level module binding \ |
| 334 | (`alias := import(\"...\")`), not inside a function body", |
| 335 | )); |
| 336 | } |
| 337 | let init = self.parse_expression()?; |
| 338 | Ok(Statement::InferredVariableDecl { name, init }) |
| 339 | } |
| 340 | Some(Token::Import) => Err(self.error( |
| 341 | "`import(...)` is only valid as a top-level module binding \ |
| 342 | (`alias := import(\"...\")`), not inside a function body", |
| 343 | )), |
| 344 | Some(_) => Ok(Statement::Expression(self.parse_expression()?)), |
| 345 | None => Err(self.error("unexpected end of input while parsing statement")), |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | fn parse_expression(&mut self) -> Result<Expression, ParserError> { |
no test coverage detected