GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — Array subexpression @($list) throws "Argument types do not match" for List[object] created by New-Object · Issue #27558 · PowerShell/PowerShell Open DescriptionSummaryThe array-subexpression operator itself throws UI Automation, Minimal reproduction$list = New-Object System.Collections.Generic.List[object] @($list) The list can be empty. Actual outputExpected output
$list = [System.Collections.Generic.List[object]]::new() @($list) # succeeds Comparisonfunction Test-Case($name, [scriptblock]$body) { try { & $body | Out-Null $name + ': OK' } catch { $name + ': FAIL - ' + $_.Exception.Message } } $newObjectList = New-Object System.Collections.Generic.List[object] $constructorList = [System.Collections.Generic.List[object]]::new() Test-Case 'New-Object + @()' { @($newObjectList) } Test-Case 'constructor + @()' { @($constructorList) } Test-Case 'New-Object + [array]' { [array]$newObjectList } Test-Case 'New-Object + ToArray' { $newObjectList.ToArray() } Observed: Both values report the same public types: The failure is specific in the tested matrix:
Stack traceThe exception occurs while evaluating Workarounds$list = [System.Collections.Generic.List[object]]::new() [array]$list $list.ToArray() In the original application, removing the unnecessary array-subexpression also avoids the failure: - controls = @($pair[1]) + controls = $pair[1] EnvironmentReproduced on:
The original report attributed the failure to UI Automation-derived hashtables and Related issues
Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |