Reviewers: aandrey, Yang,
Message:
PTAL
Description:
Do not reflect uninitialized 'let' and 'const' in scope mirrors.
[email protected],[email protected]
BUG=v8:3743
LOG=N
Please review this at https://codereview.chromium.org/758603004/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+28, -6 lines):
M src/scopeinfo.cc
M test/mjsunit/harmony/debug-blockscopes.js
Index: src/scopeinfo.cc
diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc
index
598c5e669bcfc3073182ba46fa1de0062cbae8f5..b9cb6f3ba5e2ace1eaad5cfc4378011c8ae27385
100644
--- a/src/scopeinfo.cc
+++ b/src/scopeinfo.cc
@@ -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: test/mjsunit/harmony/debug-blockscopes.js
diff --git a/test/mjsunit/harmony/debug-blockscopes.js
b/test/mjsunit/harmony/debug-blockscopes.js
index
f3a0ab9cf093d8418a3677e28efbf9c71dd14ff9..8180377e6d399a8d48d9fc2ecdf10b9ab69028eb
100644
--- a/test/mjsunit/harmony/debug-blockscopes.js
+++ b/test/mjsunit/harmony/debug-blockscopes.js
@@ -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();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.