summaryrefslogtreecommitdiffstats
path: root/js/src/frontend/Parser.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-08 15:03:53 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:15 -0400
commit986ae6266566447f22be68caf6371cbf98cafd52 (patch)
treeb07587264a039e817a5fa003f7e8060c543e1db9 /js/src/frontend/Parser.cpp
parent7ecc50d90d13690d610f26d0056a326e52bc834c (diff)
downloadUXP-986ae6266566447f22be68caf6371cbf98cafd52.tar
UXP-986ae6266566447f22be68caf6371cbf98cafd52.tar.gz
UXP-986ae6266566447f22be68caf6371cbf98cafd52.tar.lz
UXP-986ae6266566447f22be68caf6371cbf98cafd52.tar.xz
UXP-986ae6266566447f22be68caf6371cbf98cafd52.zip
636635 - Do not create named lambda binding for a function created by Function constructor.
Diffstat (limited to 'js/src/frontend/Parser.cpp')
-rw-r--r--js/src/frontend/Parser.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index a7b1f3a14..c86d9ca7b 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -2173,7 +2173,7 @@ Parser<ParseHandler>::declareDotGeneratorName()
template <typename ParseHandler>
bool
-Parser<ParseHandler>::finishFunctionScopes()
+Parser<ParseHandler>::finishFunctionScopes(bool isStandaloneFunction)
{
FunctionBox* funbox = pc->functionBox();
@@ -2182,7 +2182,7 @@ Parser<ParseHandler>::finishFunctionScopes()
return false;
}
- if (funbox->function()->isNamedLambda()) {
+ if (funbox->function()->isNamedLambda() && !isStandaloneFunction) {
if (!propagateFreeNamesAndMarkClosedOverBindings(pc->namedLambdaScope()))
return false;
}
@@ -2192,9 +2192,9 @@ Parser<ParseHandler>::finishFunctionScopes()
template <>
bool
-Parser<FullParseHandler>::finishFunction()
+Parser<FullParseHandler>::finishFunction(bool isStandaloneFunction /* = false */)
{
- if (!finishFunctionScopes())
+ if (!finishFunctionScopes(isStandaloneFunction))
return false;
FunctionBox* funbox = pc->functionBox();
@@ -2215,7 +2215,7 @@ Parser<FullParseHandler>::finishFunction()
funbox->functionScopeBindings().set(*bindings);
}
- if (funbox->function()->isNamedLambda()) {
+ if (funbox->function()->isNamedLambda() && !isStandaloneFunction) {
Maybe<LexicalScope::Data*> bindings = newLexicalScopeData(pc->namedLambdaScope());
if (!bindings)
return false;
@@ -2227,14 +2227,14 @@ Parser<FullParseHandler>::finishFunction()
template <>
bool
-Parser<SyntaxParseHandler>::finishFunction()
+Parser<SyntaxParseHandler>::finishFunction(bool isStandaloneFunction /* = false */)
{
// The LazyScript for a lazily parsed function needs to know its set of
// free variables and inner functions so that when it is fully parsed, we
// can skip over any already syntax parsed inner functions and still
// retain correct scope information.
- if (!finishFunctionScopes())
+ if (!finishFunctionScopes(isStandaloneFunction))
return false;
// There are too many bindings or inner functions to be saved into the
@@ -2354,7 +2354,7 @@ Parser<FullParseHandler>::standaloneFunction(HandleFunction fun,
YieldHandling yieldHandling = GetYieldHandling(generatorKind, asyncKind);
AutoAwaitIsKeyword awaitIsKeyword(&tokenStream, asyncKind == AsyncFunction);
if (!functionFormalParametersAndBody(InAllowed, yieldHandling, fn, Statement,
- parameterListEnd))
+ parameterListEnd, /* isStandaloneFunction = */ true))
{
return null();
}
@@ -3425,7 +3425,8 @@ bool
Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
YieldHandling yieldHandling,
Node pn, FunctionSyntaxKind kind,
- Maybe<uint32_t> parameterListEnd /* = Nothing() */)
+ Maybe<uint32_t> parameterListEnd /* = Nothing() */,
+ bool isStandaloneFunction /* = false */)
{
// Given a properly initialized parse context, try to parse an actual
// function without concern for conversion to strict mode, use of lazy
@@ -3533,7 +3534,7 @@ Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
if (IsMethodDefinitionKind(kind) && pc->superScopeNeedsHomeObject())
funbox->setNeedsHomeObject();
- if (!finishFunction())
+ if (!finishFunction(isStandaloneFunction))
return false;
handler.setEndPosition(body, pos().begin);