From dc0c896b38274ab15975da0cb105a875eb0fb0e5 Mon Sep 17 00:00:00 2001 From: rzvxa Date: Thu, 7 Mar 2024 20:48:30 +0330 Subject: [PATCH] fix(parser): issue in parsing mutable variables. --- crates/fuse-parser/src/parsers/binding.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/fuse-parser/src/parsers/binding.rs b/crates/fuse-parser/src/parsers/binding.rs index 57ee03f..e6335c5 100644 --- a/crates/fuse-parser/src/parsers/binding.rs +++ b/crates/fuse-parser/src/parsers/binding.rs @@ -28,7 +28,7 @@ impl<'a> Parser<'a> { } fn parse_binding_identifier_pattern(&mut self) -> ParserResult { - if !self.cur_kind().is_valid_identifier() { + if !self.cur_kind().is_valid_identifier() && !self.at(TokenKind::Mut) { return Err(Self::unexpected_error(self.cur_token())); } @@ -38,13 +38,12 @@ impl<'a> Parser<'a> { pub(crate) fn parse_binding_identifier(&mut self) -> BindingIdentifier { let mut span = self.start_span(); + let mutable = self.consume_if(TokenKind::Mut).is_some(); let token = self.consume(); let name = self.view_token(*token); span = self.end_span(span); - let mutable = self.consume_if(TokenKind::Mut).is_some(); - let atom = self.ast.atom(name); self.ast.binding_identifier(span, atom, mutable)