Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(883)

Unified Diff: src/parser.cc

Issue 1400973002: Throw when calling an undefined function Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/v8natives.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 9113e8c7a4e3ba46b936b38d1f4627ff0c426cf4..eaa1a6c136e7048596e345006837f697c06efb54 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1071,7 +1071,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
// pre-existing bindings should be made writable, enumerable and
// nonconfigurable if possible, whereas this code will leave attributes
// unchanged if the property already exists.
- InsertSloppyBlockFunctionVarBindings(scope, &ok);
+ InsertSloppyBlockFunctionVarBindings(scope, body, &ok);
}
if (ok && (is_strict(language_mode()) || allow_harmony_sloppy())) {
CheckConflictingVarDeclarations(scope_, &ok);
@@ -4315,7 +4315,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
CHECK_OK);
}
if (is_sloppy(language_mode) && allow_harmony_sloppy_function()) {
- InsertSloppyBlockFunctionVarBindings(scope, CHECK_OK);
+ InsertSloppyBlockFunctionVarBindings(scope, body, CHECK_OK);
}
if (is_strict(language_mode) || allow_harmony_sloppy()) {
CheckConflictingVarDeclarations(scope, CHECK_OK);
@@ -5003,7 +5003,7 @@ void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) {
}
-void Parser::InsertSloppyBlockFunctionVarBindings(Scope* scope, bool* ok) {
+void Parser::InsertSloppyBlockFunctionVarBindings(Scope* scope, ZoneList<Statement*>* body, bool* ok) {
// For each variable which is used as a function declaration in a sloppy
// block,
DCHECK(scope->is_declaration_scope());
@@ -5021,6 +5021,17 @@ void Parser::InsertSloppyBlockFunctionVarBindings(Scope* scope, bool* ok) {
DCHECK(ok); // Based on the preceding check, this should not fail
if (!ok) return;
+ // For testing, insert an initializing assignment to the function
+ // setting it to "throwLittleDan".
+ VariableProxy* littledanVariable = scope_->NewUnresolved(
+ factory(), ast_value_factory()->throwLittleDan_string(), Variable::NORMAL,
+ RelocInfo::kNoPosition, RelocInfo::kNoPosition);
+ Assignment* littledanAssignment = factory()->NewAssignment(
+ Token::ASSIGN, proxy, littledanVariable, RelocInfo::kNoPosition);
+ Statement* littledanStatement = factory()->NewExpressionStatement(
+ littledanAssignment, RelocInfo::kNoPosition);
+ body->InsertAt(0, littledanStatement, zone());
+
// Write in assignments to var for each block-scoped function declaration
auto delegates = static_cast<SloppyBlockFunctionMap::Vector*>(p->value);
for (SloppyBlockFunctionStatement* delegate : *delegates) {
« no previous file with comments | « src/parser.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698