Skip to content

'Go To Definition' does not work when the variable is defined with type hint #4443

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

Closed
6 tasks done
ALiwoto opened this issue Mar 4, 2023 · 1 comment · Fixed by PowerShell/PowerShellEditorServices#2006
Assignees

Comments

@ALiwoto
Copy link
Contributor

ALiwoto commented Mar 4, 2023

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

When defining a variable using type hint (e.g. [string]$helloStr = "hi"), Go to definition no longer works; however if I remove the [string] part the the beginning, it will work fine.

Does not work:

[string]$hello = "test"
Write-Host $hello # no definition found for '$hello'

works fine:

$hello = "test"
Write-Host $hello # it goes to the line of definition

PowerShell Version

PS> $PSVersionTable


Name                           Value
----                           -----
PSVersion                      7.3.2
PSEdition                      Core
GitCommitId                    7.3.2
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

PS> code --version


1.76.0
92da9481c0904c6adfe372c12da3b7748d74bdcb
x64

Extension Version

PS> code --list-extensions --show-versions | Select-String powershell


[email protected]

Steps to Reproduce

Define a variable while specifying its type behind it and try to press F12 (or ctrl + left-click or click on Go to definition from right-click context menu).

Visuals

image

image

Logs

No response

@ALiwoto ALiwoto added the Issue-Bug A bug to squash. label Mar 4, 2023
@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 4, 2023
@andyleejordan
Copy link
Member

Oo, good find! I'll see if I can get this fixed soon.

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

Successfully merging a pull request may close this issue.

2 participants