You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ($test-eq$null) {$test=@{}}
if ($test-eq$null) {
$test=@{ }
}
Expected behavior
This is actually what happens when $test is an array and what you should expect from an hashtable assignment.
if ($test-eq$null) { $test=@() }
if ($test-eq$null) {
$test=@()
}
Actual behavior
This is what actually happens with hashtables.
if ($test-eq$null) { $test=@{ }
}
if ($test-eq$null) {
$test=@{ }
}
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.503
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.503
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.18.0
(This is the version that comes with the latest versions of VSCode, from which this is used)
The text was updated successfully, but these errors were encountered:
Thanks for the detailed report.
First of all, I suggest to install PSSA 1.18.1 for improved formatting and speed (the extension will start picking it up after the next restart of the shell or VSCode).
Secondly, it still happens with the newer version unfortunately. The 1st line is actually sufficient for a repro if one includes the newline in the formatting selection as well:
Uh oh!
There was an error while loading. Please reload this page.
Code formatting does not behave properly when declaring a hashtable in a IF condition.
Steps to reproduce
Set your codeFormatting options in vscode to:
Write the following statement
Expected behavior
This is actually what happens when $test is an array and what you should expect from an hashtable assignment.
Actual behavior
This is what actually happens with hashtables.
Environment data
The text was updated successfully, but these errors were encountered: