Do not reflect uninitialized 'let' and 'const' in scope mirrors.
authordslomov <dslomov@chromium.org>
Mon, 8 Dec 2014 14:59:10 +0000 (06:59 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 8 Dec 2014 14:59:28 +0000 (14:59 +0000)
R=yangguo@chromium.org,aandrey@chromium.org
BUG=v8:3743
LOG=N

Review URL: https://codereview.chromium.org/758603004

Cr-Commit-Position: refs/heads/master@{#25712}

src/scopeinfo.cc
test/mjsunit/harmony/debug-blockscopes.js

index 598c5e669bcfc3073182ba46fa1de0062cbae8f5..b9cb6f3ba5e2ace1eaad5cfc4378011c8ae27385 100644 (file)
@@ -380,13 +380,14 @@ bool ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info,
   for (int i = 0; i < local_count; ++i) {
     if (scope_info->LocalIsSynthetic(first_context_var + i)) continue;
     int context_index = Context::MIN_CONTEXT_SLOTS + i;
+    Handle<Object> value = Handle<Object>(context->get(context_index), isolate);
+    // Do not reflect variables under TDZ in scope object.
+    if (value->IsTheHole()) continue;
     RETURN_ON_EXCEPTION_VALUE(
-        isolate,
-        Runtime::DefineObjectProperty(
-            scope_object,
-            Handle<String>(String::cast(scope_info->get(i + start))),
-            Handle<Object>(context->get(context_index), isolate),
-            ::NONE),
+        isolate, Runtime::DefineObjectProperty(
+                     scope_object,
+                     Handle<String>(String::cast(scope_info->get(i + start))),
+                     value, ::NONE),
         false);
   }
   return true;
index f3a0ab9cf093d8418a3677e28efbf9c71dd14ff9..8180377e6d399a8d48d9fc2ecdf10b9ab69028eb 100644 (file)
@@ -481,3 +481,24 @@ listener_delegate = function(exec_state) {
 };
 for_loop_5();
 EndTest();
+
+
+// Uninitialized variables
+BeginTest("Uninitialized 1");
+
+function uninitialized_1() {
+  {
+    debugger;
+    let x = 1;
+  }
+}
+
+listener_delegate = function(exec_state) {
+  CheckScopeChain([debug.ScopeType.Block,
+                   debug.ScopeType.Local,
+                   debug.ScopeType.Script,
+                   debug.ScopeType.Global], exec_state);
+  CheckScopeContent({}, 0, exec_state);
+};
+uninitialized_1();
+EndTest();