René's URL Explorer Experiment


Title: Array subexpression @($list) throws "Argument types do not match" for List[object] created by New-Object · Issue #27558 · PowerShell/PowerShell · GitHub

Open Graph Title: Array subexpression @($list) throws "Argument types do not match" for List[object] created by New-Object · Issue #27558 · PowerShell/PowerShell

X Title: Array subexpression @($list) throws "Argument types do not match" for List[object] created by New-Object · Issue #27558 · PowerShell/PowerShell

Description: Summary The array-subexpression operator itself throws System.ArgumentException: Argument types do not match when it wraps a System.Collections.Generic.List[object] created by New-Object. UI Automation, ConvertTo-Json, and the original $...

Open Graph Description: Summary The array-subexpression operator itself throws System.ArgumentException: Argument types do not match when it wraps a System.Collections.Generic.List[object] created by New-Object. UI Automa...

X Description: Summary The array-subexpression operator itself throws System.ArgumentException: Argument types do not match when it wraps a System.Collections.Generic.List[object] created by New-Object. UI Automa...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/27558

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Array subexpression @($list) throws \"Argument types do not match\" for List[object] created by New-Object","articleBody":"## Summary\n\nThe array-subexpression operator itself throws `System.ArgumentException: Argument types do not match` when it wraps a `System.Collections.Generic.List[object]` created by `New-Object`.\n\nUI Automation, `ConvertTo-Json`, and the original `$pair[1]` access are not required. They only made the issue visible in the original application.\n\n## Minimal reproduction\n\n```powershell\n$list = New-Object System.Collections.Generic.List[object]\n@($list)\n```\n\nThe list can be empty.\n\n### Actual output\n\n```text\nOperationStopped: Argument types do not match\n```\n\n### Expected output\n\n`@($list)` should not throw and should behave consistently with the same public .NET type created with its constructor. In the tested environment, the constructor-created empty list produces an empty `object[]`:\n\n```powershell\n$list = [System.Collections.Generic.List[object]]::new()\n@($list) # succeeds\n```\n\n## Comparison\n\n```powershell\nfunction Test-Case($name, [scriptblock]$body) {\n    try {\n        \u0026 $body | Out-Null\n        $name + ': OK'\n    }\n    catch {\n        $name + ': FAIL - ' + $_.Exception.Message\n    }\n}\n\n$newObjectList = New-Object System.Collections.Generic.List[object]\n$constructorList = [System.Collections.Generic.List[object]]::new()\n\nTest-Case 'New-Object + @()' { @($newObjectList) }\nTest-Case 'constructor + @()' { @($constructorList) }\nTest-Case 'New-Object + [array]' { [array]$newObjectList }\nTest-Case 'New-Object + ToArray' { $newObjectList.ToArray() }\n```\n\nObserved:\n\n```text\nNew-Object + @(): FAIL - Argument types do not match\nconstructor + @(): OK\nNew-Object + [array]: OK\nNew-Object + ToArray: OK\n```\n\nBoth values report the same public types:\n\n```text\nGetType():                         System.Collections.Generic.List[System.Object]\nPSObject.BaseObject type:          System.Collections.Generic.List[System.Object]\nPSObject.ImmediateBaseObject type: System.Collections.Generic.List[System.Object]\n```\n\nThe failure is specific in the tested matrix:\n\n| Construction/type | `@(...)` |\n|---|---|\n| `New-Object List[object]` | FAIL |\n| `[List[object]]::new()` | OK |\n| `New-Object List[string]` | OK |\n| `New-Object List[int]` | OK |\n| `New-Object ArrayList` | OK |\n| `New-Object Queue[object]` | OK |\n\n## Stack trace\n\nThe exception occurs while evaluating `@($list)`, before any JSON serialization. The top stack frames are:\n\n```text\nat System.Linq.Expressions.Expression.Condition(...)\nat System.Management.Automation.Language.PSEnumerableBinder.MaybeDebase(...)\nat System.Management.Automation.Language.PSToObjectArrayBinder.Bind(...)\n```\n\n## Workarounds\n\n```powershell\n$list = [System.Collections.Generic.List[object]]::new()\n[array]$list\n$list.ToArray()\n```\n\nIn the original application, removing the unnecessary array-subexpression also avoids the failure:\n\n```diff\n- controls = @($pair[1])\n+ controls = $pair[1]\n```\n\n## Environment\n\nReproduced on:\n\n- PowerShell 7.6.3 on Windows 11 10.0.26200\n- Windows PowerShell 5.1.26100.8655 on the same machine\n\nThe original report attributed the failure to UI Automation-derived hashtables and `ConvertTo-Json`. Further reduction after reviewer feedback shows that neither is required.\n\n## Related issues\n\n- [PowerShell #5579](https://github.com/PowerShell/PowerShell/issues/5579): implicit `PSObject` wrapping and serialization behavior\n- [PowerShell #4280](https://github.com/PowerShell/PowerShell/issues/4280) and [PR #4296](https://github.com/PowerShell/PowerShell/pull/4296): earlier work on array-subexpression behavior and `List[object]`\n","author":{"url":"https://github.com/shuangxue520","@type":"Person","name":"shuangxue520"},"datePublished":"2026-06-03T15:07:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/27558/PowerShell/issues/27558"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:1320126f-bf74-ea59-11f0-07e1713e6061
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBE88:3D1150:3E0BB9:51DDFD:6A5B26B8
html-safe-nonce63b0c2bbb22de00b4c7e64b3798585811ebdc440e9e7d7351eb3b59c8da09029
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTg4OjNEMTE1MDozRTBCQjk6NTFEREZEOjZBNUIyNkI4IiwidmlzaXRvcl9pZCI6IjczODcxNjcyODY3NTczOTMyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacd24c4454728a6aed142e6d57ff4f0381efeeedb6f157a3d56f04a15408d33f6e
hovercard-subject-tagissue:4581101551
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/27558/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4e8c27a76966ec139b015d4aeb8f92a45f3176364f2099dccbcece7728533706/PowerShell/PowerShell/issues/27558
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4e8c27a76966ec139b015d4aeb8f92a45f3176364f2099dccbcece7728533706/PowerShell/PowerShell/issues/27558
og:image:altSummary The array-subexpression operator itself throws System.ArgumentException: Argument types do not match when it wraps a System.Collections.Generic.List[object] created by New-Object. UI Automa...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameshuangxue520
hostnamegithub.com
expected-hostnamegithub.com
None5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9c975978430e9ad293956f2bbdaf153b1bd84a99
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/27558#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F27558
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F27558
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/27558
Reloadhttps://github.com/PowerShell/PowerShell/issues/27558
Reloadhttps://github.com/PowerShell/PowerShell/issues/27558
Please reload this pagehttps://github.com/PowerShell/PowerShell/issues/27558
PowerShell https://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Notifications https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Fork 8.4k https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Star 54.4k https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Code https://github.com/PowerShell/PowerShell
Issues 1.3k https://github.com/PowerShell/PowerShell/issues
Pull requests 289 https://github.com/PowerShell/PowerShell/pulls
Discussions https://github.com/PowerShell/PowerShell/discussions
Actions https://github.com/PowerShell/PowerShell/actions
Projects https://github.com/PowerShell/PowerShell/projects
Security and quality 3 https://github.com/PowerShell/PowerShell/security
Insights https://github.com/PowerShell/PowerShell/pulse
Code https://github.com/PowerShell/PowerShell
Issues https://github.com/PowerShell/PowerShell/issues
Pull requests https://github.com/PowerShell/PowerShell/pulls
Discussions https://github.com/PowerShell/PowerShell/discussions
Actions https://github.com/PowerShell/PowerShell/actions
Projects https://github.com/PowerShell/PowerShell/projects
Security and quality https://github.com/PowerShell/PowerShell/security
Insights https://github.com/PowerShell/PowerShell/pulse
Array subexpression @($list) throws "Argument types do not match" for List[object] created by New-Objecthttps://github.com/PowerShell/PowerShell/issues/27558#top
https://github.com/shuangxue520
shuangxue520https://github.com/shuangxue520
on Jun 3, 2026https://github.com/PowerShell/PowerShell/issues/27558#issue-4581101551
PowerShell #5579https://github.com/PowerShell/PowerShell/issues/5579
PowerShell #4280https://github.com/PowerShell/PowerShell/issues/4280
PR #4296https://github.com/PowerShell/PowerShell/pull/4296
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.