Skip to content

Commit

Permalink
fix: add test for nan to the pow of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fnll committed Jul 12, 2024
1 parent ec3e426 commit dc00126
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/swc_ecma_minifier/src/compress/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ pub(crate) fn eval_as_number(expr_ctx: &ExprCtx, e: &Expr) -> Option<f64> {
let first = eval_as_number(expr_ctx, &args[0].expr)?;
let second = eval_as_number(expr_ctx, &args[1].expr)?;

if second == 0.0 {
return Some(1.0);
}

if first.is_nan() || second.is_nan() {
return Some(f64::NAN);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"evaluate": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(Math.pow(NaN, 0));
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(1);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(1);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(1);

0 comments on commit dc00126

Please sign in to comment.