Index: src/parsing/parser.cc |
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
index 9f18790eefce3cc4ff1a4637f29cd039e5b84262..827a783437d72c6b065ca9637c2b50ce546175a8 100644 |
--- a/src/parsing/parser.cc |
+++ b/src/parsing/parser.cc |
@@ -694,6 +694,16 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { |
int beg_pos = scanner()->location().beg_pos; |
parsing_module_ = info->is_module(); |
if (parsing_module_) { |
+ // Declare the special module parameter. |
+ auto name = ast_value_factory()->empty_string(); |
+ bool is_duplicate; |
+ bool is_rest = false; |
+ bool is_optional = false; |
+ auto var = scope->DeclareParameter(name, VAR, is_optional, is_rest, |
+ &is_duplicate, ast_value_factory()); |
+ DCHECK(!is_duplicate); |
+ var->AllocateTo(VariableLocation::PARAMETER, 0); |
+ |
neis
2016/09/02 12:06:07
Here we awkwardly declare the module parameter, wh
adamk
2016/09/14 17:32:22
I feel like this might be a good question for some
|
ParseModuleItemList(body, &ok); |
ok = ok && |
module()->Validate(this->scope()->AsModuleScope(), |
@@ -737,9 +747,10 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { |
if (ok) { |
RewriteDestructuringAssignments(); |
+ int parameter_count = parsing_module_ ? 1 : 0; |
result = factory()->NewScriptOrEvalFunctionLiteral( |
scope, body, function_state.materialized_literal_count(), |
- function_state.expected_property_count()); |
+ function_state.expected_property_count(), parameter_count); |
} |
} |