Skip to content

Watched variable declared in a while retains its watched value across iterations #47602

Open
@louis-bompart

Description

@louis-bompart

Version

v18.16.0

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

Debugger

What steps will reproduce the bug?

  1. Create a file named index.js containing the following script:

    let i = 5;
    while (--i > 0) {
      const foo = "bar" + i;
    }
  2. Inspect it using node inspect index.js

  3. watch foo: watch('foo'). Optionally, watch('i') too.

  4. Go to l3 for the first time, assert that foo = undefined)

  5. Continue until you reach l3 again: the watched value of foo is then bar4 (and i=3): the debugger show the foo declared in the previous iteration

How often does it reproduce? Is there a required condition?

The reproducing steps are systematic, I reproduced similar behavior in longer scripts too

What is the expected behavior? Why is that the expected behavior?

I'd expect the watch value to stay undefined or in error until the declaration statement

What do you see instead?

image

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    debuggerIssues and PRs related to the debugger subsystem.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions