Parser - Fixed borrow error

This commit is contained in:
Emmanuel BENOîT 2023-01-12 08:46:06 +01:00
parent 4255fc30d5
commit fb588e07a2

View file

@ -229,11 +229,11 @@ impl Parser {
let static_token = self.expect(&[TokenType::Static]); let static_token = self.expect(&[TokenType::Static]);
match self.parse_function(FunctionKind::Method)? { match self.parse_function(FunctionKind::Method)? {
StmtNode::FunDecl(d) => { StmtNode::FunDecl(d) => {
if let Some(tok) = static_token { if let Some(tok) = &static_token {
if d.name.lexeme == "init" { if d.name.lexeme == "init" {
return Err(SloxError::with_token( return Err(SloxError::with_token(
ErrorKind::Parse, ErrorKind::Parse,
&tok, tok,
"initializer cannot be declared static".to_owned(), "initializer cannot be declared static".to_owned(),
)); ));
} }