From 33c94d3bd90af2ceaa3faf36cdf19c2dd8700619 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 10 Oct 2019 09:37:02 +0800 Subject: detect boolean context across IIFEs (#3461) --- lib/ast.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') 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; } -- cgit v1.2.3