| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Flags: --expose-debug-as debug --no-analyze-environment-liveness | |
| 6 | |
| 7 // Test that debug-evaluate correctly collects free outer variables | |
| 8 // and does not get confused by variables in nested scopes. | |
| 9 | |
| 10 Debug = debug.Debug | |
| 11 | |
| 12 var exception = null; | |
| 13 function listener(event, exec_state, event_data, data) { | |
| 14 if (event != Debug.DebugEvent.Break) return; | |
| 15 try { | |
| 16 assertThrows(() => exec_state.frame(0).evaluate("x").value()); | |
| 17 } catch (e) { | |
| 18 exception = e; | |
| 19 print(e + e.stack); | |
| 20 } | |
| 21 } | |
| 22 | |
| 23 Debug.setListener(listener); | |
| 24 | |
| 25 (function() { | |
| 26 var x = 1; // context allocate x | |
| 27 (() => x); | |
| 28 (function() { | |
| 29 var x = 2; // stack allocate shadowing x | |
| 30 (function() { | |
| 31 { // context allocate x in a nested scope | |
| 32 let x = 3; | |
| 33 (() => x); | |
| 34 } | |
| 35 debugger; | |
| 36 })(); | |
| 37 })(); | |
| 38 })(); | |
| 39 | |
| 40 Debug.setListener(null); | |
| 41 assertNull(exception); | |
| OLD | NEW |