Skip to content

-OutVariable doesn't unwrap single-object output and creates [System.Collections.ArrayList] values rather than [System.Object[]] #3154

@mklement0

Description

@mklement0

Note: Also affects other common parameters: see #3773

Steps to reproduce

$null = Get-Date -OutVariable ov; $ov.GetType().FullName

Expected behavior

Type name System.DateTime

Actual behavior

Type name System.Collections.ArrayList

That is, the single-object output stored in the variable targeted with -OutVariable received an array list rather than a scalar (the single-element collection wasn't unwrapped).

Also, it is type [System.Collections.ArrayList] that is always used, in contrast with the [System.Object[]] instances you get with regular assignments.

See also: http://stackoverflow.com/a/40666568/45375

Environment data

PowerShell v6.0.0-alpha (v6.0.0-alpha.15) on Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64
PowerShell v5.1.14393.693 on Microsoft Windows 10 Pro (64-bit; v10.0.14393)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking-Changebreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionResolution-AnsweredThe question is answered.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions