Skip to content

Displaying SwitchParameter causes subsequent output to fail... #15390

@rtestardi

Description

@rtestardi

Put this in a file like testme.ps1:

param(
  [switch]$skip = $false,
  [switch]$weird = $false
)

if (! $skip) {
    $weird  # skip this line and it works!
}

$hash2=@{}

$hash2["aaa"]=1

"hash value is"

$hash2

Without the -skip parameter, nothing gets printed for the hash value...

PS C:\temp> powershell .\testme.ps1

IsPresent
---------
    False
hash value is

PS C:\temp> powershell .\testme.ps1 -skip
hash value is

Name                           Value
----                           -----
aaa                            1

PS C:\temp>

I would have expected the hash value output to be the same in both cases?

I see the same behavior on Core 7.1.3 and Desktop 5.1.19041.906.

Is there a workaround?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreWG-Engine-Format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions