Index: src/scopes.cc |
diff --git a/src/scopes.cc b/src/scopes.cc |
index 9a6e3aae6da4d72b705970990826e3fd78308f90..8c99044e72b57a659ad49953331d04e129d62dac 100644 |
--- a/src/scopes.cc |
+++ b/src/scopes.cc |
@@ -180,6 +180,7 @@ void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope, |
num_global_slots_ = 0; |
num_modules_ = 0; |
module_var_ = NULL; |
+ arity_ = 0; |
has_simple_parameters_ = true; |
rest_parameter_ = NULL; |
rest_index_ = -1; |
@@ -465,10 +466,12 @@ Variable* Scope::Lookup(const AstRawString* name) { |
} |
-Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode, |
- bool is_rest, bool* is_duplicate) { |
+Variable* Scope::DeclareParameter( |
+ const AstRawString* name, VariableMode mode, |
+ bool is_optional, bool is_rest, bool* is_duplicate) { |
DCHECK(!already_resolved()); |
DCHECK(is_function_scope()); |
+ DCHECK(!is_optional || !is_rest); |
Variable* var; |
if (mode == TEMPORARY) { |
var = NewTemporary(name); |
@@ -479,6 +482,9 @@ Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode, |
// TODO(wingo): Avoid O(n^2) check. |
*is_duplicate = IsDeclaredParameter(name); |
} |
+ if (!is_optional && !is_rest && arity_ == params_.length()) { |
+ ++arity_; |
+ } |
if (is_rest) { |
DCHECK_NULL(rest_parameter_); |
rest_parameter_ = var; |