aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-10-10 09:37:02 +0800
committerGitHub <noreply@github.com>2019-10-10 09:37:02 +0800
commit33c94d3bd90af2ceaa3faf36cdf19c2dd8700619 (patch)
treebcffafb1f07c09ec229b7fe48e0e009f80b4907f /lib
parentb18f717b46d655aa183d09109e1e6cbbc4462c04 (diff)
downloadtracifyjs-33c94d3bd90af2ceaa3faf36cdf19c2dd8700619.tar.gz
tracifyjs-33c94d3bd90af2ceaa3faf36cdf19c2dd8700619.zip
detect boolean context across IIFEs (#3461)
Diffstat (limited to 'lib')
-rw-r--r--lib/ast.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/ast.js b/lib/ast.js
index 6205cc77..5e1fbbb9 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -979,6 +979,14 @@ TreeWalker.prototype = {
|| p instanceof AST_Conditional
|| p.tail_node() === self) {
self = p;
+ } else if (p instanceof AST_Return) {
+ var fn;
+ do {
+ fn = this.parent(++i);
+ if (!fn) return false;
+ } while (!(fn instanceof AST_Lambda));
+ self = this.parent(++i);
+ if (!self || self.TYPE != "Call" || self.expression !== fn) return false;
} else {
return false;
}