Skip to content

panic on division by zero #780

@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("1n/0n");
}

Expected behavior

An Error

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

Stacktrace:

thread 'main' panicked at 'attempt to divide by zero', /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.3.0/src/algorithms.rs:600:9
stack backtrace:
   0: std::panicking::begin_panic
             at /home/capitol/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:505
   1: num_bigint::biguint::algorithms::div_rem_ref
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.3.0/src/algorithms.rs:600
   2: <num_bigint::biguint::BigUint as num_integer::Integer>::div_rem
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.3.0/src/biguint.rs:1492
   3: <num_bigint::bigint::BigInt as num_integer::Integer>::div_rem
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.3.0/src/bigint.rs:2222
   4: <&num_bigint::bigint::BigInt as core::ops::arith::Div<&num_bigint::bigint::BigInt>>::div
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.3.0/src/bigint.rs:1716
   5: <num_bigint::bigint::BigInt as core::ops::arith::DivAssign<&num_bigint::bigint::BigInt>>::div_assign
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.3.0/src/bigint.rs:1724
   6: <num_bigint::bigint::BigInt as core::ops::arith::DivAssign>::div_assign
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.3.0/src/macros.rs:114
   7: boa::builtins::bigint::operations::<impl core::ops::arith::Div for boa::builtins::bigint::BigInt>::div
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/builtins/bigint/operations.rs:42
   8: boa::value::operations::<impl boa::value::Value>::div
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/value/operations.rs:109
   9: boa::exec::operator::<impl boa::exec::Executable for boa::syntax::ast::node::operator::BinOp>::run
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/exec/operator/mod.rs:62
  10: <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:107
  11: 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
  12: boa::context::Context::eval
             at /home/capitol/.cargo/registry/src/github.com-1ecc6299db9ec823/Boa-0.10.0/src/context.rs:494
  13: boa_reproduce::main
             at ./src/main.rs:3
  14: 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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions