Skip to content

Commit

Permalink
fix corner case in unused
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Jul 1, 2018
1 parent 6aa7500 commit 5ffc17d
Show file tree
Hide file tree
Showing 56 changed files with 1,573 additions and 958 deletions.
2 changes: 1 addition & 1 deletion lib/ast.js
Expand Up @@ -328,7 +328,7 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", {
var body = this.body;
var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
wrapped_tl = parse(wrapped_tl);
wrapped_tl = wrapped_tl.transform(new TreeTransformer(function before(node) {
wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
if (node instanceof AST_Directive && node.value == "$ORIG") {
return MAP.splice(body);
}
Expand Down
351 changes: 175 additions & 176 deletions lib/compress.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions test/compress/arrays.js
Expand Up @@ -15,9 +15,9 @@ holes_and_undefined: {

constant_join: {
options = {
unsafe : true,
evaluate : true
};
evaluate: true,
unsafe: true,
}
input: {
var a = [ "foo", "bar", "baz" ].join("");
var a1 = [ "foo", "bar", "baz" ].join();
Expand Down Expand Up @@ -64,9 +64,9 @@ constant_join: {

constant_join_2: {
options = {
unsafe : true,
evaluate : true
};
evaluate: true,
unsafe: true,
}
input: {
var a = [ "foo", "bar", boo(), "baz", "x", "y" ].join("");
var b = [ "foo", "bar", boo(), "baz", "x", "y" ].join("-");
Expand All @@ -93,9 +93,9 @@ constant_join_2: {

constant_join_3: {
options = {
unsafe: true,
evaluate: true,
};
unsafe: true,
}
input: {
var a = [ null ].join();
var b = [ , ].join();
Expand Down Expand Up @@ -133,7 +133,7 @@ for_loop: {
reduce_vars: true,
unsafe: true,
unused: true,
};
}
input: {
function f0() {
var a = [1, 2, 3];
Expand Down
38 changes: 19 additions & 19 deletions test/compress/asm.js
@@ -1,24 +1,24 @@
asm_mixed: {
options = {
sequences : true,
properties : true,
dead_code : true,
drop_debugger : true,
conditionals : true,
comparisons : true,
evaluate : true,
booleans : true,
loops : true,
unused : true,
hoist_funs : true,
keep_fargs : true,
keep_fnames : false,
hoist_vars : true,
if_return : true,
join_vars : true,
side_effects : true,
negate_iife : true
};
booleans: true,
comparisons: true,
conditionals: true,
dead_code: true,
drop_debugger: true,
evaluate: true,
hoist_funs: true,
hoist_vars: true,
if_return: true,
join_vars: true,
keep_fargs: true,
keep_fnames: false,
loops: true,
negate_iife: true,
properties: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
// adapted from http://asmjs.org/spec/latest/
function asm_GeometricMean(stdlib, foreign, buffer) {
Expand Down

0 comments on commit 5ffc17d

Please sign in to comment.