New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 748315 link

Starred by 2 users

Issue metadata

Status: Duplicate
Merged: issue 498454
Owner:
Last visit > 30 days ago
Closed: Oct 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Inherited argument variables in nested functions appear to be treated differently in the debugger

Reported by lolbum...@gmail.com, Jul 25 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

Steps to reproduce the problem:
1. Open the console
2. Run the following code:
```
var foo = function(bar) {
    return {
        baz: function() {
            [1, 2, 3, 4, 5].forEach(function() {
                debugger;
            });
        }
    }
};
var x = foo('hello');
x.baz();
```
3. When the debugger hits, attempt to get the value of bar.

What is the expected behavior?
The console should yield `hello`.

What went wrong?
Uncaught ReferenceError: bar is not defined
    at eval (eval at <anonymous> (:5:17), <anonymous>:1:1)
    at <anonymous>:5:17
    at Array.forEach (<anonymous>)
    at Object.baz (<anonymous>:4:29)
    at <anonymous>:11:3

Did this work before? N/A 

Chrome version: 59.0.3071.115  Channel: stable
OS Version: OS X 10.12.5
Flash Version: 

If you reference bar anywhere inside of that function before the debugger, all works as expected.
 
Labels: Needs-Milestone
Labels: -OS-Mac OS-All
Owner: kozyatinskiy@chromium.org
Status: Assigned (was: Unconfirmed)
This is a known problem: since |bar| is not used anywhere it is optimized out by V8. This makes it impossible to reference it using debugger.

Not sure what's the plan here, and even if we can do anything. Alexey?

Note that easy workaround is to set a breakpoint directly in |foo|, so that |bar| parameter is available.

Mergedinto: 498454
Status: Duplicate (was: Assigned)

Sign in to add a comment