| Index: src/scopes.cc
|
| diff --git a/src/scopes.cc b/src/scopes.cc
|
| index 8b623f90ce908ac548bfd8ea46bdcf088121bbcf..ff72cabb8e12f18605d1fed36d8889b7d9cbea68 100644
|
| --- a/src/scopes.cc
|
| +++ b/src/scopes.cc
|
| @@ -387,9 +387,12 @@ Scope* Scope::FinalizeBlockScope() {
|
| }
|
|
|
|
|
| -Variable* Scope::LookupLocal(const AstRawString* name) {
|
| +Variable* Scope::LookupLocal(const AstRawString* name, bool parameters_only) {
|
| Variable* result = variables_.Lookup(name);
|
| if (result != NULL || scope_info_.is_null()) {
|
| + if (result != NULL && parameters_only && !params_.Contains(result)) {
|
| + result = NULL;
|
| + }
|
| return result;
|
| }
|
| Handle<String> name_handle = name->string();
|
| @@ -453,11 +456,16 @@ Variable* Scope::LookupFunctionVar(const AstRawString* name,
|
|
|
|
|
| Variable* Scope::Lookup(const AstRawString* name) {
|
| + bool parameters_only = false;
|
| for (Scope* scope = this;
|
| scope != NULL;
|
| scope = scope->outer_scope()) {
|
| - Variable* var = scope->LookupLocal(name);
|
| + Variable* var = scope->LookupLocal(name, parameters_only);
|
| if (var != NULL) return var;
|
| +
|
| + // if current scope is a parameter scope, the outer scope must be a
|
| + // function scope, and should only search the function parameters
|
| + parameters_only = scope->is_parameter_scope();
|
| }
|
| return NULL;
|
| }
|
| @@ -819,6 +827,7 @@ static const char* Header(ScopeType scope_type) {
|
| case BLOCK_SCOPE: return "block";
|
| case WITH_SCOPE: return "with";
|
| case ARROW_SCOPE: return "arrow";
|
| + case PARAMETER_SCOPE: return "parameter";
|
| }
|
| UNREACHABLE();
|
| return NULL;
|
| @@ -1013,7 +1022,8 @@ Variable* Scope::NonLocal(const AstRawString* name, VariableMode mode) {
|
|
|
| Variable* Scope::LookupRecursive(VariableProxy* proxy,
|
| BindingKind* binding_kind,
|
| - AstNodeFactory* factory) {
|
| + AstNodeFactory* factory,
|
| + bool parameters_only) {
|
| DCHECK(binding_kind != NULL);
|
| if (already_resolved() && is_with_scope()) {
|
| // Short-cut: if the scope is deserialized from a scope info, variable
|
| @@ -1023,7 +1033,7 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy,
|
| }
|
|
|
| // Try to find the variable in this scope.
|
| - Variable* var = LookupLocal(proxy->raw_name());
|
| + Variable* var = LookupLocal(proxy->raw_name(), parameters_only);
|
|
|
| // We found a variable and we are done. (Even if there is an 'eval' in
|
| // this scope which introduces the same variable again, the resulting
|
| @@ -1041,7 +1051,8 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy,
|
| if (var != NULL) {
|
| *binding_kind = BOUND;
|
| } else if (outer_scope_ != NULL) {
|
| - var = outer_scope_->LookupRecursive(proxy, binding_kind, factory);
|
| + var = outer_scope_->LookupRecursive(proxy, binding_kind, factory,
|
| + is_parameter_scope());
|
| if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) {
|
| var->ForceContextAllocation();
|
| }
|
| @@ -1085,7 +1096,8 @@ bool Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy,
|
|
|
| // Otherwise, try to resolve the variable.
|
| BindingKind binding_kind;
|
| - Variable* var = LookupRecursive(proxy, &binding_kind, factory);
|
| + Variable* var = LookupRecursive(proxy, &binding_kind, factory,
|
| + is_parameter_scope());
|
| switch (binding_kind) {
|
| case BOUND:
|
| // We found a variable binding.
|
|
|