From fe8eae981d5854cf618dbbb29d07aa637f6e25d8 Mon Sep 17 00:00:00 2001 From: gluax Date: Tue, 23 Mar 2021 11:32:36 -0400 Subject: [PATCH] const_ self as function input --- parser/src/parser/file.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/parser/src/parser/file.rs b/parser/src/parser/file.rs index b590c35f3e..a298095a26 100644 --- a/parser/src/parser/file.rs +++ b/parser/src/parser/file.rs @@ -327,13 +327,13 @@ impl ParserContext { self.expect_ident()? }; if name.name == "self" { - if const_.is_some() { - //error - } if let Some(mutable) = &mutable { name.span = &mutable.span + &name.span; name.name = "mut self".to_string(); return Ok(FunctionInput::MutSelfKeyword(MutSelfKeyword { identifier: name })); + } else if let Some(const_) = &const_ { + name.span = &const_.span + &name.span; + name.name = "const self".to_string(); } return Ok(FunctionInput::SelfKeyword(SelfKeyword { identifier: name })); } @@ -347,8 +347,8 @@ impl ParserContext { self.expect(Token::Colon)?; let type_ = self.parse_type()?.0; Ok(FunctionInput::Variable(FunctionInputVariable { - const_: const_.is_some(), - mutable: const_.is_none(), + const_: const_.is_some() || (const_.is_none() && mutable.is_none()), + mutable: mutable.is_some(), type_, span: name.span.clone(), identifier: name,