Skip to content

[parser UpdateExpression] panics when the prefix/postfix increment/decrement target is a number #779

@alexanderkjall

Description

@alexanderkjall

Describe the bug

Expected an Error, not a panic.

To Reproduce

Can be reproduced with this program:

fn main() {
    let mut context = boa::Context::new();
    let _ = context.eval("--245");
}

Expected behavior

An Error, not a panic

Build environment (please complete the following information):

  • OS: Ubuntu 20.04
  • Version: 0.10.0
  • Target triple: [e.g. x86_64-unknown-linux-gnu]
  • Rustc version: 1.48.0-nightly (d006f5734 2020-08-28)

Additional context
Full stacktrace:

thread 'main' panicked at 'TypeError: invalid assignment to 245', /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/context.rs:438:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d006f5734f49625c34d6fc33bf6b9967243abca8/library/std/src/panicking.rs:483
   1: std::panicking::begin_panic_fmt
             at /rustc/d006f5734f49625c34d6fc33bf6b9967243abca8/library/std/src/panicking.rs:437
   2: boa::context::Context::set_value
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/context.rs:438
   3: boa::exec::operator::<impl boa::exec::Executable for boa::syntax::ast::node::operator::UnaryOp>::run
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/exec/operator/mod.rs:206
   4: <boa::syntax::ast::node::Node as boa::exec::Executable>::run
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/exec/mod.rs:108
   5: boa::exec::statement_list::<impl boa::exec::Executable for boa::syntax::ast::node::statement_list::StatementList>::run
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/exec/statement_list.rs:17
   6: boa::context::Context::eval
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/context.rs:494
   7: boa_reproduce::main
             at ./src/main.rs:3
   8: core::ops::function::FnOnce::call_once
             at /home/capitol/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions