Skip to content

Erroneous variable assigned but never used #1388

@shawnr13

Description

@shawnr13

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions