Skip to content
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

Evaluate expression returns variable value from wrong scope #1882

Open
3 tasks done
fflaten opened this issue Aug 12, 2022 · 0 comments
Open
3 tasks done

Evaluate expression returns variable value from wrong scope #1882

fflaten opened this issue Aug 12, 2022 · 0 comments
Labels
Area-Debugging Issue-Bug A bug to squash. Up for Grabs Will shepherd PRs.

Comments

@fflaten
Copy link
Contributor

fflaten commented Aug 12, 2022

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

$myVarName = 123
& {
    $myVarName = 456
    $myVarName           # breakpoint here
}

While debugging the script above and stopped at line 4 ($myVarName), evaluate debugger call using context: 'watch', expression: '$myVarName' returns the value from parent scope (123).

Simply changing the expression to $myVarName; returns the local value (456). This points us in the direction of this method as source of the bug.

// First check to see if the watch expression refers to a naked variable reference.
result = _debugService.GetVariableFromExpression(request.Expression);

The evaluate-call in my scenario is made through using new vscode.InlineValueEvaluatableExpression(range, expression) which VSCode executes here

Expected behavior

evaluate should return the local value (456). The local value is shown in Variable Explorer, PSIC and by inline using vscode.InlineValueVariableLookup while stopped at the same location.

Actual behavior

Returns 123.

After executing $script:myVarName or $global:myVarName in PSIC and using step over, evaluate returns the newest value (no scope-preference/-priority).

Changing $myVarName in PSIC + step over updates variable explorer + vscode.InlineValueVariableLookup result, but evaluate doesn't care - still showing the latest parent-scope value.

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

2022.7.2

Visuals

No response

@ghost ghost added the Needs: Triage Maintainer attention needed! label Aug 12, 2022
@fflaten fflaten changed the title Evaluate expression event returns variable value from wrong scope Evaluate expression returns variable value from wrong scope Aug 12, 2022
@SydneyhSmith SydneyhSmith added Issue-Bug A bug to squash. Up for Grabs Will shepherd PRs. Area-Debugging and removed Needs: Triage Maintainer attention needed! labels Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debugging Issue-Bug A bug to squash. Up for Grabs Will shepherd PRs.
Projects
None yet
Development

No branches or pull requests

2 participants