diff --git a/js/src/frontend/FoldConstants.cpp b/js/src/frontend/FoldConstants.cpp index ed176a27d4..0e27a09404 100644 --- a/js/src/frontend/FoldConstants.cpp +++ b/js/src/frontend/FoldConstants.cpp @@ -1544,9 +1544,13 @@ FoldCall(ExclusiveContext* cx, BinaryNode* node, Parser& parse // assertEq((true ? obj.f : null)``, "global"); // assertEq(obj.f``, "obj"); // + // As an exception to this, we do allow folding the function in + // `(function() { ... })()` (the module pattern), because that lets us + // constant fold code inside that function. + // // See bug 537673 and bug 1182373. ParseNode* callee = node->left(); - if (node->isKind(PNK_NEW) || !callee->isInParens()) { + if (node->isKind(PNK_NEW) || !callee->isInParens() || callee->is()) { if (!Fold(cx, node->unsafeLeftReference(), parser, inGenexpLambda)) return false; }