Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

v5 Regression: Casting object[] to more narrow generic collection fails with a single element, but not with two #2208

Copy link
Copy link
@oising

Description

@oising
Issue body actions

Steps to reproduce

> [Collections.Generic.List[int]]@(1)

or

> [Management.Automation.LanguagePrimitives]::ConvertTo(@(1), [Collections.Generic.List[int]])

Note that casting @(1,2) will succeed. Only the case @(1) fails. This is a regression because it functions correctly in v4.

Expected behavior

Casts to an instance of List<int> containing a single element: 1

Actual behavior

Exception calling "ConvertTo" with "2" argument(s): "Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Int32"."

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.0.10586.494
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.10586.494
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.