Compare commits

...

5 Commits

Author SHA1 Message Date
Mihai Bazon
15b5f70338 v2.6.1 2015-11-16 12:10:47 +02:00
Mihai Bazon
7f48d5b33c Fix endless loop
Close #866
2015-11-16 12:08:24 +02:00
Mihai Bazon
b6968b6bd2 Limit max iterations for tighten_body
Ref #866
2015-11-16 12:08:24 +02:00
Richard van Velzen
08b80302eb Merge pull request #864 from plievone/patch-1
Fix docs for keep_fargs
2015-11-14 12:04:49 +01:00
plievone
645626ebe8 Fix docs for keep_fargs
Compression options `keep_fargs` and `unsafe` were decoupled in v.2.5.0 (commit 5fd1245), so document actual keep_fargs default.
2015-11-14 11:38:00 +02:00
3 changed files with 10 additions and 6 deletions

View File

@@ -348,7 +348,7 @@ to set `true`; it's effectively a shortcut for `foo=true`).
- `drop_console` -- default `false`. Pass `true` to discard calls to - `drop_console` -- default `false`. Pass `true` to discard calls to
`console.*` functions. `console.*` functions.
- `keep_fargs` -- default `false`. Pass `true` to prevent the - `keep_fargs` -- default `true`. Prevents the
compressor from discarding unused function arguments. You need this compressor from discarding unused function arguments. You need this
for code which relies on `Function.length`. for code which relies on `Function.length`.
@@ -372,7 +372,6 @@ when this flag is on:
- `void 0` → `undefined` (if there is a variable named "undefined" in - `void 0` → `undefined` (if there is a variable named "undefined" in
scope; we do it because the variable name will be mangled, typically scope; we do it because the variable name will be mangled, typically
reduced to a single character) reduced to a single character)
- discards unused function arguments (affects `function.length`)
### Conditional compilation ### Conditional compilation

View File

@@ -199,7 +199,7 @@ merge(Compressor.prototype, {
}; };
function tighten_body(statements, compressor) { function tighten_body(statements, compressor) {
var CHANGED; var CHANGED, max_iter = 10;
do { do {
CHANGED = false; CHANGED = false;
if (compressor.option("angular")) { if (compressor.option("angular")) {
@@ -218,7 +218,7 @@ merge(Compressor.prototype, {
if (compressor.option("join_vars")) { if (compressor.option("join_vars")) {
statements = join_consecutive_vars(statements, compressor); statements = join_consecutive_vars(statements, compressor);
} }
} while (CHANGED); } while (CHANGED && max_iter-- > 0);
if (compressor.option("negate_iife")) { if (compressor.option("negate_iife")) {
negate_iifes(statements, compressor); negate_iifes(statements, compressor);
@@ -384,7 +384,12 @@ merge(Compressor.prototype, {
continue loop; continue loop;
} }
//--- //---
if (ret.length == 1 && in_lambda && ret[0] instanceof AST_SimpleStatement // XXX: what was the intention of this case?
// if sequences is not enabled, this can lead to an endless loop (issue #866).
// however, with sequences on this helps producing slightly better output for
// the example code.
if (compressor.option("sequences")
&& ret.length == 1 && in_lambda && ret[0] instanceof AST_SimpleStatement
&& (!stat.alternative || stat.alternative instanceof AST_SimpleStatement)) { && (!stat.alternative || stat.alternative instanceof AST_SimpleStatement)) {
CHANGED = true; CHANGED = true;
ret.push(make_node(AST_Return, ret[0], { ret.push(make_node(AST_Return, ret[0], {

View File

@@ -4,7 +4,7 @@
"homepage": "http://lisperator.net/uglifyjs", "homepage": "http://lisperator.net/uglifyjs",
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)", "author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"version": "2.6.0", "version": "2.6.1",
"engines": { "engines": {
"node": ">=0.8.0" "node": ">=0.8.0"
}, },