Title: Duplicate using namespace statements cause all type refs to throw AmbigiousTypeReference · Issue #13525 · PowerShell/PowerShell · GitHub
Open Graph Title: Duplicate using namespace statements cause all type refs to throw AmbigiousTypeReference · Issue #13525 · PowerShell/PowerShell
X Title: Duplicate using namespace statements cause all type refs to throw AmbigiousTypeReference · Issue #13525 · PowerShell/PowerShell
Description: Steps to reproduce using namespace System.Text using namespace System.Text [StringBuilder] Expected behavior Either ignore the second using namespace or throw parse error Actual behavior InvalidArgument: Line | 5 | [StringBuilder] | ~~~~...
Open Graph Description: Steps to reproduce using namespace System.Text using namespace System.Text [StringBuilder] Expected behavior Either ignore the second using namespace or throw parse error Actual behavior InvalidArg...
X Description: Steps to reproduce using namespace System.Text using namespace System.Text [StringBuilder] Expected behavior Either ignore the second using namespace or throw parse error Actual behavior InvalidArg...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/13525
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Duplicate using namespace statements cause all type refs to throw AmbigiousTypeReference","articleBody":"\u003c!--\r\n\r\nFor Windows PowerShell 5.1 issues, suggestions, or feature requests please use the following link instead:\r\nWindows PowerShell [UserVoice](https://windowsserver.uservoice.com/forums/301869-powershell)\r\n\r\nThis repository is **ONLY** for PowerShell Core 6 and PowerShell 7+ issues.\r\n\r\n- Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- Search the existing issues.\r\n- Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- Refer to the [known issues](https://docs.microsoft.com/powershell/scripting/whats-new/known-issues-ps6).\r\n\r\n-->\r\n\r\n## Steps to reproduce\r\n\r\n```powershell\r\nusing namespace System.Text\r\nusing namespace System.Text\r\n\r\n[StringBuilder]\r\n```\r\n\r\n## Expected behavior\r\n\r\nEither ignore the second `using namespace` or throw parse error\r\n\r\n## Actual behavior\r\n\r\n```none\r\nInvalidArgument:\r\nLine |\r\n 5 | [StringBuilder]\r\n | ~~~~~~~~~~~~~~~\r\n | Type name 'StringBuilder' is ambiguous, it could be 'System.Text.StringBuilder' or 'System.Text.StringBuilder'.\r\n```\r\n\r\n^ is thrown at runtime.\r\n\r\n## Environment data\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```none\r\nName Value\r\n---- -----\r\nPSVersion 7.1.0-preview.6\r\nPSEdition Core\r\nGitCommitId 7.1.0-preview.6\r\nOS Microsoft Windows 10.0.18362\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n\r\n## Notes\r\n\r\n\u003cdetails>\r\n\r\n\u003csummary>Full Get-Error output (click to expand)\u003c/summary>\r\n\r\n```raw\r\nException :\r\n Type : System.Management.Automation.RuntimeException\r\n ErrorRecord :\r\n Exception :\r\n Type : System.Management.Automation.ParentContainsErrorRecordException\r\n Message : Type name 'StringBuilder' is ambiguous, it could be 'System.Text.StringBuilder' or 'System.Text.StringBuilder'.\r\n HResult : -2146233087\r\n CategoryInfo : InvalidArgument: (:) [], ParentContainsErrorRecordException\r\n FullyQualifiedErrorId : AmbiguousTypeReference\r\n InvocationInfo :\r\n ScriptLineNumber : 5\r\n OffsetInLine : 1\r\n HistoryId : -1\r\n Line : [StringBuilder]\r\n PositionMessage : At line:5 char:1\r\n + [StringBuilder]\r\n + ~~~~~~~~~~~~~~~\r\n CommandOrigin : Internal\r\n ScriptStackTrace : at \u003cScriptBlock>, \u003cNo file>: line 5\r\n Message : Type name 'StringBuilder' is ambiguous, it could be 'System.Text.StringBuilder' or 'System.Text.StringBuilder'.\r\n InnerException :\r\n Type : System.Management.Automation.PSInvalidCastException\r\n ErrorRecord :\r\n Exception :\r\n Type : System.Management.Automation.ParentContainsErrorRecordException\r\n Message : Type name 'StringBuilder' is ambiguous, it could be 'System.Text.StringBuilder' or 'System.Text.StringBuilder'.\r\n HResult : -2146233087\r\n CategoryInfo : InvalidArgument: (:) [], ParentContainsErrorRecordException\r\n FullyQualifiedErrorId : AmbiguousTypeReference\r\n InvocationInfo :\r\n ScriptLineNumber : 5\r\n OffsetInLine : 1\r\n HistoryId : -1\r\n Line : [StringBuilder]\r\n PositionMessage : At line:5 char:1\r\n + [StringBuilder]\r\n + ~~~~~~~~~~~~~~~\r\n CommandOrigin : Internal\r\n ScriptStackTrace : at \u003cScriptBlock>, \u003cNo file>: line 5\r\n TargetSite :\r\n Name : ResolveTypeName\r\n DeclaringType : System.Management.Automation.TypeOps, System.Management.Automation, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\n MemberType : Method\r\n Module : System.Management.Automation.dll\r\n StackTrace :\r\n at System.Management.Automation.TypeOps.ResolveTypeName(ITypeName typeName, IScriptExtent errorPos)\r\n at System.Management.Automation.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame frame)\r\n at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\r\n Message : Type name 'StringBuilder' is ambiguous, it could be 'System.Text.StringBuilder' or 'System.Text.StringBuilder'.\r\n Data : System.Collections.ListDictionaryInternal\r\n InnerException :\r\n Type : System.Management.Automation.Language.TypeResolver+AmbiguousTypeException\r\n Candidates :\r\n Length : 25\r\n\r\n Length : 25\r\n TypeName : StringBuilder\r\n Message : Specified cast is not valid.\r\n HResult : -2147467262\r\n Source : System.Management.Automation\r\n HResult : -2147467262\r\n HResult : -2146233087\r\nCategoryInfo : InvalidArgument: (:) [], RuntimeException\r\nFullyQualifiedErrorId : AmbiguousTypeReference\r\nInvocationInfo :\r\n ScriptLineNumber : 5\r\n OffsetInLine : 1\r\n HistoryId : -1\r\n Line : [StringBuilder]\r\n PositionMessage : At line:5 char:1\r\n + [StringBuilder]\r\n + ~~~~~~~~~~~~~~~\r\n CommandOrigin : Internal\r\nScriptStackTrace : at \u003cScriptBlock>, \u003cNo file>: line 5\r\n```\r\n\r\n\u003c/details>\r\n\r\nSide note, I found this because I had duplicated `using namespace System` in a script I dot sourced. `System` is a real bad one to do that with since it breaks concise view *for the rest of the session*. Took me awhile to figure out what was happening, thought I broke `Out-Default` somehow. Might be a good idea to use the fully qualified name for `Environment` in concise view (/cc @SteveL-MSFT).","author":{"url":"https://github.com/SeeminglyScience","@type":"Person","name":"SeeminglyScience"},"datePublished":"2020-08-26T18:34:03Z","url":"https://github.com/PowerShell/PowerShell/issues/13525"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:31367856-2f4b-3345-2b13-252b6acfcfcd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A28:26FF81:2E5A51:418106:6AFDB40E |
| html-safe-nonce | 88554d062622efc9c35fe9ebc89139068e59c432ea5d8bf2b69034a6e347d51c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTI4OjI2RkY4MToyRTVBNTE6NDE4MTA2OjZBRkRCNDBFIiwidmlzaXRvcl9pZCI6IjIwNjAzMDU4NTEwMjQ3ODIzNTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 397cd91f93bf5bcc6abc20ecef71835aaaafff891e450d1c7eb5d9a561213b21 |
| hovercard-subject-tag | issue:686530618 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/13525/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9d3b661e6313496e6151f06065703db94ee9d717814f062c4c585e6220024e6b/PowerShell/PowerShell/issues/13525 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9d3b661e6313496e6151f06065703db94ee9d717814f062c4c585e6220024e6b/PowerShell/PowerShell/issues/13525 |
| og:image:alt | Steps to reproduce using namespace System.Text using namespace System.Text [StringBuilder] Expected behavior Either ignore the second using namespace or throw parse error Actual behavior InvalidArg... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SeeminglyScience |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3c532f4d069d6fbe9b1837450343d1b9e0619a7d5c4ba0b3b64fd8e0bae67c7e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5396ad00d1c6d19097aee7fc4d00a2eb03432c8f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width