| Index: src/ast/scopes.h
|
| diff --git a/src/ast/scopes.h b/src/ast/scopes.h
|
| index 6c261f63c376fdf9357eb06ad8cf397f1c08a9ec..cca7905595477d3a427542709a95dcbc454e2c11 100644
|
| --- a/src/ast/scopes.h
|
| +++ b/src/ast/scopes.h
|
| @@ -428,7 +428,24 @@ class Scope: public ZoneObject {
|
| // Returns the default function arity excluding default or rest parameters.
|
| int default_function_length() const { return arity_; }
|
|
|
| - int num_parameters() const { return params_.length(); }
|
| + // Returns the number of formal parameters, up to but not including the
|
| + // rest parameter index (if the function has rest parameters), i.e. it
|
| + // says 2 for
|
| + //
|
| + // function foo(a, b) { ... }
|
| + //
|
| + // and
|
| + //
|
| + // function foo(a, b, ...c) { ... }
|
| + //
|
| + // but for
|
| + //
|
| + // function foo(a, b, c = 1) { ... }
|
| + //
|
| + // we return 3 here.
|
| + int num_parameters() const {
|
| + return has_rest_parameter() ? params_.length() - 1 : params_.length();
|
| + }
|
|
|
| // A function can have at most one rest parameter. Returns Variable* or NULL.
|
| Variable* rest_parameter(int* index) const {
|
|
|