Skip to content

Erroneous variable assigned but never used #1388

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
shawnr13 opened this issue Jun 27, 2018 · 2 comments
Closed

Erroneous variable assigned but never used #1388

shawnr13 opened this issue Jun 27, 2018 · 2 comments

Comments

@shawnr13
Copy link

Issue Type: Bug

Setting a variable inside a foreach-object loop, it shows the variable as assigned but never used, when it is used outside of the foreach.
Example for replication:

$Array |ForEach-Object {$NewVar = 1};$NewVar

My original problem the first time I set $Added, it has no green squiggle line and appears fine (it recognizes the variable is used later on), but within the foreach-object the same variable is shown as being assigned but never used.:

$Added = 0
If ($Adds) {$Adds |ForEach-Object {Try {$Added += 1}Catch {}}}
$AddsElement.SetAttribute("Success",$Added)

Extension version: 1.7.0
VS Code version: Code 1.24.1 (24f62626b222e9a8313213fb64b10d741a326288, 2018-06-13T17:51:32.889Z)
OS version: Windows_NT x64 10.0.15063

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz (8 x 2904)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: disabled_software
video_decode: enabled
video_encode: enabled
vpx_decode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 31.88GB (22.61GB free)
Process Argv C:\Program Files\Microsoft VS Code\Code.exe
Screen Reader no
VM 0%
![image](https://user-images.githubusercontent.com/2037684/41980862-8a85ca12-79f5-11e8-923c-82fb383e22bd.png)
@shawnr13
Copy link
Author

after another search, I DID find the same issue.
PowerShell/PSScriptAnalyzer#827
Thumbs upping that one and closing this one.

@rjmholt
Copy link
Contributor

rjmholt commented Jun 27, 2018

From the looks of things, this should be fixed in our next release

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

No branches or pull requests

2 participants