[Pkg-javascript-commits] [uglifyjs] 151/190: Never produce -0 when evaluating expressions (like -"")
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:21 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.
commit 27eedbc302dea6a2af558bbf6bc8865fd2410837
Author: Richard van Velzen <rvanvelzen at experty.com>
Date: Tue May 17 22:34:38 2016 +0200
Never produce -0 when evaluating expressions (like -"")
Fix for #1085. The major case was already there, but more expressions can result in -0.
---
lib/compress.js | 6 +++---
test/compress/evaluate.js | 9 +++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index 6436796..e8c42c0 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1029,9 +1029,9 @@ merge(Compressor.prototype, {
case "void": return void ev(e, compressor);
case "~": return ~ev(e, compressor);
case "-":
- e = ev(e, compressor);
- if (e === 0) throw def;
- return -e;
+ e = -ev(e, compressor);
+ if (e === -0) throw def;
+ return e;
case "+": return +ev(e, compressor);
}
throw def;
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js
new file mode 100644
index 0000000..9aa6b3d
--- /dev/null
+++ b/test/compress/evaluate.js
@@ -0,0 +1,9 @@
+negative_zero: {
+ options = { evaluate: true }
+ input: {
+ assert.sameValue(-"", -0, '-""');
+ }
+ expect: {
+ assert.sameValue(-"", -0, '-""');
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list