Skip to content

Commit 25b73bb

Browse files
committed
bugfixes and test fixes
1 parent 2d9252c commit 25b73bb

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

lib/Parser.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ class StackedSetMap {
7777
return this.defaultValue;
7878
}
7979

80+
_compress() {
81+
this.map = new Map();
82+
for(const data of this.stack) {
83+
for(const pair of data) {
84+
this.map.set(pair[0], pair[1]);
85+
}
86+
}
87+
this.stack = [this.map];
88+
}
89+
90+
asSet() {
91+
this._compress();
92+
return new Set(Array.from(this.map.entries()).filter(pair => pair[1]).map(pair => pair[0]));
93+
}
94+
8095
createChild() {
8196
return new StackedSetMap(this.defaultValue, this.stack);
8297
}
@@ -1493,7 +1508,7 @@ class Parser extends Tapable {
14931508
if(expr.type === "Identifier") {
14941509
free = !this.scope.definitions.has(expr.name);
14951510
exprName.push(this.scope.renames.get(expr.name) || expr.name);
1496-
} else if(expr.type === "ThisExpression" && this.scope.renames.$this) {
1511+
} else if(expr.type === "ThisExpression" && this.scope.renames.get("this")) {
14971512
free = true;
14981513
exprName.push(this.scope.renames.get("this"));
14991514
} else if(expr.type === "ThisExpression") {

test/Parser.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ describe("Parser", () => {
219219
});
220220
testParser.plugin("expression fgh", (expr) => {
221221
if(!testParser.state.fgh) testParser.state.fgh = [];
222-
testParser.state.fgh.push(testParser.scope.definitions.join(" "));
222+
testParser.state.fgh.push(Array.from(testParser.scope.definitions.asSet()).join(" "));
223223
return true;
224224
});
225225
testParser.plugin("expression fgh.sub", (expr) => {

0 commit comments

Comments
 (0)