Different results between using [ref] and [System.Management.Automation.PSReference] - by jrjespersen

Status : 

 


5
0
Sign in
to vote
ID 776044 Comments
Status Active Workarounds
Type Bug Repros 1
Opened 1/8/2013 7:13:00 AM
Access Restriction Public

Description

Running this code on PowerShell 3.0 produces different results for $x and $y:

$x = $false
$y = $false
[Boolean]::TryParse("true", [System.Management.Automation.PSReference] $x)
[Boolean]::TryParse("true", [ref] $y)

I would expect both values to be true, as is the case on PowerShell 1.0 and 2.0.
Sign in to post a comment.
Posted by Joel 'Jaykul' Bennett on 1/9/2013 at 12:53 PM
Yep. Bottom line: this is a regression from v2
Posted by jrjespersen on 1/8/2013 at 7:48 AM
An more straight-forward example to illustrate this is:

[bool]$x2=$false
[bool]$y=$false

[ref]$xref1=[System.Management.Automation.PSReference]$x2
[ref]$xref2=[ref]$x2
$x2 = $true

$xref1.value
$xref2.value
$x2

This clearly shows that $xref1 is not a reference to $x (and only in PowerShell 3.0).