Skip to content

PSScriptAnalyzer incorrectly scopes variables in begin/process/end scriptblock #804

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

Open
kborowinski opened this issue Jul 29, 2017 · 2 comments

Comments

@kborowinski
Copy link

PSScriptAnalyzer incorrectly adds scope to begin/process/end scriptblocks when it should treat them as one scope:

hashtable

@TimCurwick
Copy link
Contributor

This also happens in the ForEach method:

$Script = @'
$A = @()
(1..2).ForEach{ $A += $_ }
$A
'@

Invoke-ScriptAnalyzer -ScriptDefinition $Script | Select -ExpandProperty Message

The variable 'A' is assigned but never used.

@desk7
Copy link

desk7 commented Mar 19, 2023

Bug still exists today and it is very annoying.

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

No branches or pull requests

4 participants