diff options
Diffstat (limited to 'cli/tools/repl/editor.rs')
-rw-r--r-- | cli/tools/repl/editor.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cli/tools/repl/editor.rs b/cli/tools/repl/editor.rs index fbdda3f5c..a40b6fcd1 100644 --- a/cli/tools/repl/editor.rs +++ b/cli/tools/repl/editor.rs @@ -2,8 +2,10 @@ use crate::colors; use deno_ast::swc::parser::error::SyntaxError; +use deno_ast::swc::parser::token::BinOpToken; use deno_ast::swc::parser::token::Token; use deno_ast::swc::parser::token::Word; +use deno_ast::view::AssignOp; use deno_core::anyhow::Context as _; use deno_core::error::AnyError; use deno_core::parking_lot::Mutex; @@ -235,6 +237,12 @@ impl Validator for EditorHelper { for item in deno_ast::lex(ctx.input(), deno_ast::MediaType::TypeScript) { if let deno_ast::TokenOrComment::Token(token) = item.inner { match token { + Token::BinOp(BinOpToken::Div) + | Token::AssignOp(AssignOp::DivAssign) => { + // it's too complicated to write code to detect regular expression literals + // which are no longer tokenized, so if a `/` or `/=` happens, then we bail + return Ok(ValidationResult::Valid(None)); + } Token::BackQuote => in_template = !in_template, Token::LParen | Token::LBracket |