-
Couldn't load subscription status.
- Fork 240
When the built-in $null was watched its value was incorrect
#2097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Tada!
thegraffix
commented
Nov 14, 2023
Just curious - does this PR address other cases in which $null -eq $var == $true in the WATCH list as well? The built-in $null: "" wasn't the only case in which a null value was represented as an empty string "" e.g. an unitilialized variable should be shown as $VarThatDoesNotExist: $null and not $VarThatDoesNotExist: "".
Hm, I hadn't tried $VarThatDoesNotExist and it wasn't in the issue, so probably not. I can take a look. Anything else you know about?
thegraffix
commented
Nov 15, 2023
Ha no problem - $VarThatDoesNotExist is actually mentioned in the first bullet point of the issue and also in the screenshot. When debugging a PowerShell script, I would except all cases where $null -eq XYZ == $true would show XYZ: $null in the WATCH pane -- rather than sometimes XYZ: $null and other times XYZ: "". There's some MS Learn documentation on some of the subtleties of evaluating $null.
203877b to
dfb8199
Compare
Ok I took another look at this and now not only do I have answer as to why $null was being evaluated to "", I fixed the root cause 🥳
This fixes the evaluation of `$null` itself and variables that don't exist such that they display correctly in the watched variables pane of the debugger. As noted, the issue was that we were doing a string join even for a single (potentially null) value. This also fixes the excess quotes bug around a single value.
dfb8199 to
3dd91d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
No idea why its value was
"", but it was, so we special case it and return$nulljust like you get from watched variables that were assigned the built-in$null.Resolves PowerShell/vscode-powershell#4816.