Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: src/runtime/runtime-scopes.cc

Issue 1382513003: Test for var declarations in eval which conflict with let (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 // TODO(verwaest): Unify the encoding indicating "var" with DeclareGlobals. 217 // TODO(verwaest): Unify the encoding indicating "var" with DeclareGlobals.
218 bool is_var = *initial_value == NULL; 218 bool is_var = *initial_value == NULL;
219 bool is_const = initial_value->IsTheHole(); 219 bool is_const = initial_value->IsTheHole();
220 bool is_function = initial_value->IsJSFunction(); 220 bool is_function = initial_value->IsJSFunction();
221 DCHECK_EQ(1, 221 DCHECK_EQ(1,
222 BoolToInt(is_var) + BoolToInt(is_const) + BoolToInt(is_function)); 222 BoolToInt(is_var) + BoolToInt(is_const) + BoolToInt(is_function));
223 223
224 int index; 224 int index;
225 PropertyAttributes attributes; 225 PropertyAttributes attributes;
226 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; 226 ContextLookupFlags flags;
227 BindingFlags binding_flags; 227 BindingFlags binding_flags;
228
229 // Check for a conflict with a lexically scoped variable
230 flags = LEXICAL_TEST;
adamk 2015/10/05 17:20:36 Rather than re-assignining this variable it seems
Dan Ehrenberg 2015/10/08 23:01:26 Done
231 context_arg->Lookup(name, flags, &index, &attributes, &binding_flags);
adamk 2015/10/05 17:20:36 It seems a shame to do this extra context chain wa
Dan Ehrenberg 2015/10/08 23:01:26 Done
232 if (attributes != ABSENT && (binding_flags == MUTABLE_CHECK_INITIALIZED ||
233 binding_flags == IMMUTABLE_CHECK_INITIALIZED)) {
234 return ThrowRedeclarationError(isolate, name);
235 }
236
237 flags = DONT_FOLLOW_CHAINS;
228 Handle<Object> holder = 238 Handle<Object> holder =
229 context->Lookup(name, flags, &index, &attributes, &binding_flags); 239 context->Lookup(name, flags, &index, &attributes, &binding_flags);
230 if (holder.is_null()) { 240 if (holder.is_null()) {
231 // In case of JSProxy, an exception might have been thrown. 241 // In case of JSProxy, an exception might have been thrown.
232 if (isolate->has_pending_exception()) return isolate->heap()->exception(); 242 if (isolate->has_pending_exception()) return isolate->heap()->exception();
233 } 243 }
234 244
235 Handle<JSObject> object; 245 Handle<JSObject> object;
236 Handle<Object> value = 246 Handle<Object> value =
237 is_function ? initial_value 247 is_function ? initial_value
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 1171
1162 // Lookup in the initial Object.prototype object. 1172 // Lookup in the initial Object.prototype object.
1163 Handle<Object> result; 1173 Handle<Object> result;
1164 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1174 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1165 isolate, result, 1175 isolate, result,
1166 Object::GetProperty(isolate->initial_object_prototype(), key)); 1176 Object::GetProperty(isolate->initial_object_prototype(), key));
1167 return *result; 1177 return *result;
1168 } 1178 }
1169 } // namespace internal 1179 } // namespace internal
1170 } // namespace v8 1180 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698