deno icon indicating copy to clipboard operation
deno copied to clipboard

Panic on `invalid` assignment with parentheses

Open Jabolol opened this issue 1 year ago • 0 comments

When creating an assignment that should error by adding parentheses around the left operand in Deno's REPL, Deno panics instead of throwing a parse error.

Steps to reproduce

  1. Open the Deno REPL
  2. Execute the following code
(1) = 1

Expected behaviour

> 1 = 1
parse error: Invalid assignment target at 1:1

actual behaviour

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos x86_64
Version: 1.45.2
Args: ["deno"]

thread 'main' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_transforms_base-0.140.3/src/fixer.rs:198:64:
called `Result::unwrap()` on an `Err` value: Lit(Num(Number { span: 2..3#0, value: 1.0, raw: Some("1") }))
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <swc_ecma_transforms_base::fixer::Fixer as swc_ecma_visit::VisitMut>::visit_mut_expr
   4: <swc_ecma_transforms_base::fixer::Fixer as swc_ecma_visit::VisitMut>::visit_mut_stmt
   5: swc_ecma_visit::visit_mut_module_items
   6: <swc_ecma_transforms_base::fixer::Fixer as swc_ecma_visit::VisitMut>::visit_mut_module
   7: <swc_ecma_ast::module::Program as swc_ecma_visit::FoldWith<V>>::fold_with
   8: deno_ast::transpiling::fold_program
   9: deno_ast::transpiling::transpile
  10: deno_ast::transpiling::<impl deno_ast::parsed_source::ParsedSource>::transpile
  11: deno::tools::repl::session::ReplSession::evaluate_ts_expression::{{closure}}
  12: deno::tools::repl::session::ReplSession::evaluate_line_with_object_wrapping::{{closure}}
  13: deno::tools::repl::session::ReplSession::evaluate_line_and_get_output::{{closure}}
  14: deno::tools::repl::run::{{closure}}
  15: deno::spawn_subcommand::{{closure}}
  16: <deno_unsync::task::MaskFutureAsSend<F> as core::future::future::Future>::poll
  17: tokio::runtime::task::raw::poll
  18: deno::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Jabolol avatar Jul 14 '24 20:07 Jabolol