-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Refiling Dart-Code/Dart-Code#5363 here after discussion between @DanTup and @bkonyi
Describe the bug
In some scenarios (see reproduction below), the debugger shows the wrong (a stale, previous) value of a class field. This can make debugging super confusing, since the actual behavior of the code doesn't match what the debugger is showing.
To Reproduce
Here's a simple piece of code that reproduces the issue.
class A {
List list;
A(this.list) {
this.list = [3];
print(list);
}
}
void main() {
A([1, 2]);
}If you put a breakpoint on the print statement, you'll see two values of list depending on whether it is preceded by this..
With mouse-over on list in the print statement:
With mouse-over on this.list, which is the same variable:
You can also see something similar going on in the variables window:
The pattern appears to be related to the constructor containing this. referencing a field of the class, then whether or not further references to that variable include this. or not controls whether you get the latest or a stale value for that variable.
The output of the program is as expected:
[3]
Expected behavior
Variable values shown by the debugger match reality and are consistent, regardless of whether an unnecessary this. is included.
Screenshots
(see above)
Please complete the following information:
You can run the Dart: Collect Diagnostic Information command from the VS Code command palette (F1) to easily capture this information or provide it manually.
- Operating System and version: Windows 11 + WSL
- VS Code version: 1.95.3
- Dart extension version: v3.102.0
- Dart/Flutter SDK version: 3.5.4 (stable) (None) on "linux_x64", no Flutter
- Target device (if the issue relates to Flutter debugging):
See details below:
Workspace Environment
Dart Code extension: 3.102.0
App: Visual Studio Code
App Host: desktop
Remote: wsl
Host Kind: wsl
Version: linux 1.95.3
Workspace type: Dart (LSP)
Workspace name: thislist [WSL: Ubuntu]
Dart (3.5.4): /usr/lib/dart
Flutter (undefined): undefined (No device)
Output from 'dart info'
/usr/lib/dart/bin/dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
General info
- Dart 3.5.4 (stable) (None) on "linux_x64"
- on linux / Linux 5.15.167.4-microsoft-standard-WSL2 Process tests sometimes cause timeout on Linux #1 SMP Tue Nov 5 00:21:55 UTC 2024
- locale is C.UTF-8
Project info
- sdk constraint: '^3.5.4'
- dependencies:
- dev_dependencies: lints, test


