Fixups after merge

This commit is contained in:
Richard van Velzen
2016-04-18 15:51:32 +02:00
parent f94497d1d6
commit 68cc14f846
4 changed files with 24 additions and 17 deletions

View File

@@ -294,6 +294,13 @@ var AST_Scope = DEFNODE("Scope", "is_block_scope directives variables functions
parent_scope: "[AST_Scope?/S] link to the parent scope",
enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
},
get_defun_scope: function () {
var self = this;
while (self.is_block_scope && self.parent_scope) {
self = self.parent_scope;
}
return self;
}
}, AST_Block);

View File

@@ -323,7 +323,7 @@ merge(Compressor.prototype, {
if (side_effects_encountered |= lvalues_encountered) continue;
// Non-constant single use vars can only be replaced in same scope.
if (ref.scope !== self) {
if (ref.scope.get_defun_scope() !== self) {
side_effects_encountered |= var_decl.value.has_side_effects(compressor);
continue;
}

View File

@@ -117,13 +117,13 @@ regression_block_scope_resolves: {
expect: {
(function () {
if (1) {
let a;
const b;
let o;
const n;
class c {};
}
if (1) {
let a;
const b;
let o;
const n;
class c {};
}
console.log(x, y, Zee, ex, why, Zi);

View File

@@ -62,9 +62,9 @@ shorthand_properties: {
return value;
})();
expect: (function() {
var a = 1;
const b = {prop:a};
return b;
var n = 1;
const r = {prop:n};
return r;
})();
}
@@ -271,8 +271,8 @@ class_name_can_be_mangled: {
expect: {
function x() {
class a { }
var b = a
var c = class a {}
var n = a
var r = class a {}
}
}
}
@@ -354,13 +354,13 @@ import_statement_mangling: {
Whatever();
}
expect: {
import a from "foo";
import b, {Food as c} from "lel";
import {What as d} from "lel";
a();
b();
c();
d();
import l from "foo";
import e, {Food as o} from "lel";
import {What as f} from "lel";
l();
e();
o();
f();
}
}