File tree Expand file tree Collapse file tree 2 files changed +43
-31
lines changed
Expand file tree Collapse file tree 2 files changed +43
-31
lines changed Original file line number Diff line number Diff line change @@ -339,7 +339,8 @@ public bool IsUninitialized(VariableExpressionAst varTarget)
339339 }
340340
341341 return analysis . DefinedBlock == null
342- && ! SpecialVars . InitializedVariables . Contains ( analysis . Name , StringComparer . OrdinalIgnoreCase )
342+ && ! ( SpecialVars . InitializedVariables . Contains ( analysis . Name , StringComparer . OrdinalIgnoreCase ) ||
343+ SpecialVars . InitializedVariables . Contains ( analysis . RealName , StringComparer . OrdinalIgnoreCase ) )
343344 && ! IsGlobalOrEnvironment ( varTarget ) ;
344345 }
345346
Original file line number Diff line number Diff line change 1- function Test {
2- $initialized = " Initialized"
3- $noglobal = " local"
4- $env: ShouldNotRaiseError
5- }
6-
7- $a = 3 ;
8-
9- if ($true ) {
10- $a = 4 ;
11- $c = 3 ;
12- } else {
13- $b = 5 ;
14- $c = 4 ;
15- }
16-
17- $b = 6 ;
18- $a ;
19- $b ;
20-
21- stop-process 12 , 23 - ErrorVariable ev - ErrorAction SilentlyContinue
22- if ($null -ne $ev )
23- {
24- Write-host $ev [0 ]
25- # no error should be raised here
26- Invoke-Command {$b }
27- }
28-
29- get-process notepad | tee-object - variable proc
30- $proc [0 ]
1+ function Test {
2+ $initialized = " Initialized"
3+ $noglobal = " local"
4+ $env: ShouldNotRaiseError
5+ }
6+
7+ $a = 3 ;
8+
9+ if ($true ) {
10+ $a = 4 ;
11+ $c = 3 ;
12+ } else {
13+ $b = 5 ;
14+ $c = 4 ;
15+ }
16+
17+ $b = 6 ;
18+ $a ;
19+ $b ;
20+
21+ stop-process 12 , 23 - ErrorVariable ev - ErrorAction SilentlyContinue
22+ if ($null -ne $ev )
23+ {
24+ Write-host $ev [0 ]
25+ # no error should be raised here
26+ Invoke-Command {$b }
27+ }
28+
29+ get-process notepad | tee-object - variable proc
30+ $proc [0 ]
31+
32+ function Test-PreferenceVariable
33+ {
34+
35+ if (-not $PSBoundParameters.ContainsKey (' Verbose' )) {
36+ $VerbosePreference = $PSCmdlet.GetVariableValue (' VerbosePreference' ) -as
37+ [System.Management.Automation.ActionPreference ]
38+ }
39+
40+ $VerbosePreference
41+ }
You can’t perform that action at this time.
0 commit comments