| Index: src/variables.cc | 
| diff --git a/src/variables.cc b/src/variables.cc | 
| index c0b8bd784353aa0ad349689b30ce7578de80e116..ffa82edcb7dd2af15935cf8099d7a434006ba111 100644 | 
| --- a/src/variables.cc | 
| +++ b/src/variables.cc | 
| @@ -50,6 +50,15 @@ Variable::Variable(Scope* scope, const AstRawString* name, VariableMode mode, | 
| is_used_(false), | 
| initialization_flag_(initialization_flag), | 
| maybe_assigned_(maybe_assigned_flag) { | 
| +  if (scope && scope->is_function_body_scope()) { | 
| +    // The function body is the proper declaration scope, however, the | 
| +    // declaration is added to the outer scope in order to ensure allocation | 
| +    // works correctly. Mark the scope as the outer scope here so that | 
| +    // checking the declaration context works. | 
| +    scope_ = scope->outer_scope(); | 
| +    DCHECK(scope_->is_function_scope()); | 
| +  } | 
| + | 
| // Var declared variables never need initialization. | 
| DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization)); | 
| } | 
|  |