Created
August 19, 2020 20:22
-
-
Save jorendorff/bf8b03a75b438d5e29e903829cddb91b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/js/src/frontend/NameAnalysisTypes.h b/js/src/frontend/NameAnalysisTypes.h | |
index 261b52771ab6..b9daa8ba5959 100644 | |
--- a/js/src/frontend/NameAnalysisTypes.h | |
+++ b/js/src/frontend/NameAnalysisTypes.h | |
@@ -124,6 +124,10 @@ static inline bool DeclarationKindIsLexical(DeclarationKind kind) { | |
return BindingKindIsLexical(DeclarationKindToBindingKind(kind)); | |
} | |
+enum class ClosedOver : bool { | |
+ No = false, Yes = true | |
+}; | |
+ | |
// Used in Parser to track declared names. | |
class DeclaredNameInfo { | |
uint32_t pos_; | |
@@ -135,8 +139,9 @@ class DeclaredNameInfo { | |
bool closedOver_; | |
public: | |
- explicit DeclaredNameInfo(DeclarationKind kind, uint32_t pos) | |
- : pos_(pos), kind_(kind), closedOver_(false) {} | |
+ explicit DeclaredNameInfo(DeclarationKind kind, uint32_t pos, | |
+ ClosedOver closedOver = ClosedOver::No) | |
+ : pos_(pos), kind_(kind), closedOver_(bool(closedOver)) {} | |
// Needed for InlineMap. | |
DeclaredNameInfo() = default; | |
diff --git a/js/src/frontend/ParseContext.cpp b/js/src/frontend/ParseContext.cpp | |
index a1c152d5b44a..0ffa7fef9489 100644 | |
--- a/js/src/frontend/ParseContext.cpp | |
+++ b/js/src/frontend/ParseContext.cpp | |
@@ -642,15 +642,16 @@ bool ParseContext::declareFunctionArgumentsObject( | |
} | |
bool ParseContext::declareDotGeneratorName() { | |
- // The special '.generator' binding must be on the function scope, as | |
- // generators expect to find it on the CallObject. | |
+ // The special '.generator' binding must be on the function scope, and must | |
+ // be marked closed-over, as generators expect to find it on the CallObject. | |
ParseContext::Scope& funScope = functionScope(); | |
HandlePropertyName dotGenerator = sc()->cx_->parserNames().dotGenerator; | |
AddDeclaredNamePtr p = funScope.lookupDeclaredNameForAdd(dotGenerator); | |
- if (!p && | |
- !funScope.addDeclaredName(this, p, dotGenerator, DeclarationKind::Var, | |
- DeclaredNameInfo::npos)) { | |
- return false; | |
+ if (!p) { | |
+ if (!funScope.addDeclaredName(this, p, dotGenerator, DeclarationKind::Var, | |
+ DeclaredNameInfo::npos, ClosedOver::Yes)) { | |
+ return false; | |
+ } | |
} | |
return true; | |
} | |
diff --git a/js/src/frontend/ParseContext.h b/js/src/frontend/ParseContext.h | |
index 6716363c8844..ee402099bfa1 100644 | |
--- a/js/src/frontend/ParseContext.h | |
+++ b/js/src/frontend/ParseContext.h | |
@@ -11,6 +11,7 @@ | |
#include "frontend/BytecodeCompiler.h" | |
#include "frontend/CompilationInfo.h" | |
#include "frontend/ErrorReporter.h" | |
+#include "frontend/NameAnalysisTypes.h" // DeclaredNameInfo | |
#include "frontend/NameCollections.h" | |
#include "frontend/SharedContext.h" | |
#include "frontend/UsedNameTracker.h" | |
@@ -150,9 +151,9 @@ class ParseContext : public Nestable<ParseContext> { | |
MOZ_MUST_USE bool addDeclaredName(ParseContext* pc, AddDeclaredNamePtr& p, | |
JSAtom* name, DeclarationKind kind, | |
- uint32_t pos) { | |
+ uint32_t pos, ClosedOver closedOver = ClosedOver::No) { | |
return maybeReportOOM( | |
- pc, declared_->add(p, name, DeclaredNameInfo(kind, pos))); | |
+ pc, declared_->add(p, name, DeclaredNameInfo(kind, pos, closedOver))); | |
} | |
// Add a FunctionBox as a possible candidate for Annex B.3.3 semantics. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment