Comparing version 5.27.1 to 5.27.2
# Changelog | ||
## v5.27.2 | ||
- Recognise `this` as a reference to the surrounding class in `drop_unused`. Closes #1472 | ||
## v5.27.1 | ||
@@ -4,0 +7,0 @@ - Fixed case where `collapse_vars` inlines `await` expressions into non-async functions. |
@@ -73,2 +73,3 @@ /*********************************************************************** | ||
AST_SymbolVar, | ||
AST_This, | ||
AST_Toplevel, | ||
@@ -130,2 +131,3 @@ AST_Unary, | ||
}; | ||
var this_def = null; | ||
var in_use_ids = new Map(); | ||
@@ -142,2 +144,3 @@ var fixed_ids = new Map(); | ||
var initializations = new Map(); | ||
// pass 1: find out which symbols are directly used in | ||
@@ -155,7 +158,2 @@ // this scope (not in nested scopes). | ||
if (node === self) return; | ||
if (node instanceof AST_Class) { | ||
if (node.has_side_effects(compressor)) { | ||
node.visit_nondeferred_class_parts(tw); | ||
} | ||
} | ||
if (node instanceof AST_Defun || node instanceof AST_DefClass) { | ||
@@ -170,2 +168,9 @@ var node_def = node.name.definition(); | ||
if (node instanceof AST_DefClass && node.has_side_effects(compressor)) { | ||
const save_this_def = this_def; | ||
this_def = node_def; | ||
node.visit_nondeferred_class_parts(tw); | ||
this_def = save_this_def; | ||
} | ||
map_add(initializations, node_def.id, node); | ||
@@ -176,2 +181,6 @@ return true; // don't go in nested scopes | ||
const in_root_scope = scope === self; | ||
if (node instanceof AST_This && this_def && in_root_scope) { | ||
in_use_ids.set(this_def.id, this_def); | ||
return true; | ||
} | ||
if (node instanceof AST_SymbolFunarg && in_root_scope) { | ||
@@ -178,0 +187,0 @@ map_add(var_defs_by_id, node.definition().id, node); |
@@ -7,3 +7,3 @@ { | ||
"license": "BSD-2-Clause", | ||
"version": "5.27.1", | ||
"version": "5.27.2", | ||
"engines": { | ||
@@ -10,0 +10,0 @@ "node": ">=10" |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2125374
60424