diff --git a/CHANGELOG.md b/CHANGELOG.md index 53453d06..c3381004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed `TokenReference::symbol("//=")` returning DoubleSlash + UnexpectedToken when `luau` and `lua53` are enabled together + ## [1.1.1] - 2024-11-16 ### Fixed diff --git a/full-moon/src/tokenizer/lexer.rs b/full-moon/src/tokenizer/lexer.rs index 47a2e7d1..ed03fb53 100644 --- a/full-moon/src/tokenizer/lexer.rs +++ b/full-moon/src/tokenizer/lexer.rs @@ -577,32 +577,31 @@ impl Lexer { '/' => { version_switch!(self.lua_version, { - lua53 => { - if self.source.current() == Some('/') { - self.source.next(); - return self.create( - start_position, - TokenType::Symbol { - symbol: Symbol::DoubleSlash, - }, - ); - } - } - luau => { + lua53 | luau => { if self.source.consume('/') { - if self.source.consume('=') { - return self.create(start_position, TokenType::Symbol { symbol: Symbol::DoubleSlashEqual }) - } else { - return self.create(start_position, TokenType::Symbol { symbol: Symbol::DoubleSlash} ) - } - } else if self.source.consume('=') { - return self.create( - start_position, - TokenType::Symbol { - symbol: Symbol::SlashEqual, - }, - ); + version_switch!(self.lua_version, { + luau => { + if self.source.consume('=') { + return self.create(start_position, TokenType::Symbol { symbol: Symbol::DoubleSlashEqual }) + } + } + }); + + return self.create(start_position, TokenType::Symbol { symbol: Symbol::DoubleSlash} ); } + + version_switch!(self.lua_version, { + luau => { + if self.source.consume('=') { + return self.create( + start_position, + TokenType::Symbol { + symbol: Symbol::SlashEqual, + }, + ); + } + } + }); } });