Title: Parser error on daily PowerShell 7.3. build · Issue #16870 · PowerShell/PowerShell · GitHub
Open Graph Title: Parser error on daily PowerShell 7.3. build · Issue #16870 · PowerShell/PowerShell
X Title: Parser error on daily PowerShell 7.3. build · Issue #16870 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/16870
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Parser error on daily PowerShell 7.3. build","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nI have complex in-house module that started to fail to import on recent daily builds of PS 7.3. It is working correctly on PS 5.1 and PS 7.2.1 and on older daily builds of PS 7.3. I was able to narrow the offending code to the following:\r\n```powershell\r\nGet-CimInstance -ClassName 'Win32_NetworkAdapterConfiguration' |\r\n\tWhere-Object -Property IPEnabled |\r\n\tForEach-Object {\r\n\t\t[IPAddress]::Parse(\r\n\t\t\t$_.IPSubnet[\r\n\t\t\t\t[Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n\t\t\t]\r\n\t\t)\r\n\t}\r\n```\r\n\r\nError:\r\n```powershell\r\nParserError: D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:6\r\nLine |\r\n 6 | [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n | ~\r\n | Missing ] at end of type token.\r\n\r\n```\r\n\r\nThe *fix* is to enclose the ` [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])` in extra pair of parentheses. Like so:\r\n```powershell\r\nGet-CimInstance -ClassName 'Win32_NetworkAdapterConfiguration' |\r\n\tWhere-Object -Property IPEnabled |\r\n\tForEach-Object {\r\n\t\t[IPAddress]::Parse(\r\n\t\t\t$_.IPSubnet[\r\n\t\t\t\t([Array]::IndexOf($_.IPAddress, $_.IPAddress[0]))\r\n\t\t\t]\r\n\t\t)\r\n\t}\r\n```\r\nBut as I mentioned before the original code is working on PS 5.1, PS 7.2.1 and older daily builds of PS 7.3 so it has to be a recent change in the PS 7.3 code that is causing this.\r\n\r\n### Expected behavior\r\n\r\n```console\r\n. .\\Test.ps1\r\n\r\nAddressFamily : InterNetwork\r\nScopeId :\r\nIsIPv6Multicast : False\r\nIsIPv6LinkLocal : False\r\nIsIPv6SiteLocal : False\r\nIsIPv6Teredo : False\r\nIsIPv6UniqueLocal : False\r\nIsIPv4MappedToIPv6 : False\r\nAddress : 16777215\r\nIPAddressToString : 255.255.255.0\r\n```\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\n. .\\Test.ps1\r\nParserError: D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:6\r\nLine |\r\n 6 | [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n | ~\r\n | Missing ] at end of type token.\r\n```\r\n\r\n\r\n### Error details\r\n\r\n```console\r\nException :\r\n Type : System.Management.Automation.ParseException\r\n Errors :\r\n Extent :\r\n ErrorId : EndSquareBracketExpectedAtEndOfType\r\n Message : Missing ] at end of type token.\r\n\r\n Extent :\r\n ErrorId : MissingEndParenthesisInMethodCall\r\n Message : Missing ')' in method call.\r\n\r\n Extent : ]\r\n ErrorId : UnexpectedToken\r\n Message : Unexpected token ']' in expression or statement.\r\n\r\n Extent : {\r\n ErrorId : MissingEndCurlyBrace\r\n Message : Missing closing '}' in statement block or type definition.\r\n\r\n Extent : )\r\n ErrorId : UnexpectedToken\r\n Message : Unexpected token ')' in expression or statement.\r\n\r\n Extent : }\r\n ErrorId : UnexpectedToken\r\n Message : Unexpected token '}' in expression or statement.\r\n Message : At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:6 char:11\r\n + [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n + ~\r\n Missing ] at end of type token.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:6 char:52\r\n + [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n + ~\r\n Missing ')' in method call.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:7 char:4\r\n + ]\r\n + ~\r\n Unexpected token ']' in expression or statement.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:3 char:17\r\n + ForEach-Object {\r\n + ~\r\n Missing closing '}' in statement block or type definition.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:8 char:3\r\n + )\r\n + ~\r\n Unexpected token ')' in expression or statement.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:9 char:2\r\n + }\r\n + ~\r\n Unexpected token '}' in expression or statement.\r\n ErrorRecord :\r\n Exception :\r\n Type : System.Management.Automation.ParentContainsErrorRecordException\r\n Message : At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:6 char:11\r\n + [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n + ~\r\n Missing ] at end of type token.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:6 char:52\r\n + [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n + ~\r\n Missing ')' in method call.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:7 char:4\r\n + ]\r\n + ~\r\n Unexpected token ']' in expression or statement.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:3 char:17\r\n + ForEach-Object {\r\n + ~\r\n Missing closing '}' in statement block or type definition.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:8 char:3\r\n + )\r\n + ~\r\n Unexpected token ')' in expression or statement.\r\n\r\n At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:9 char:2\r\n + }\r\n + ~\r\n Unexpected token '}' in expression or statement.\r\n HResult : -2146233087\r\n CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException\r\n FullyQualifiedErrorId : EndSquareBracketExpectedAtEndOfType\r\n InvocationInfo :\r\n ScriptLineNumber : 6\r\n OffsetInLine : 11\r\n HistoryId : -1\r\n ScriptName : D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1\r\n Line : [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n\r\n PositionMessage : At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:6 char:11\r\n + [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n + ~\r\n PSScriptRoot : D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\r\n PSCommandPath : D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1\r\n CommandOrigin : Internal\r\n ScriptStackTrace : at \u003cScriptBlock\u003e, \u003cNo file\u003e: line 1\r\n TargetSite :\r\n Name : Create\r\n DeclaringType : scriptblock\r\n MemberType : Method\r\n Module : System.Management.Automation.dll\r\n Data : System.Collections.ListDictionaryInternal\r\n Source : System.Management.Automation\r\n HResult : -2146233087\r\n StackTrace :\r\n at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents) in\r\nD:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\runtime\\CompiledScriptBlock.cs:line 660\r\n at System.Management.Automation.ExternalScriptInfo.ParseScriptContents(Parser parser, String fileName, String fileContents, Nullable`1 definingLanguageMode) in\r\nD:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\ExternalScriptInfo.cs:line 263\r\n at System.Management.Automation.ExternalScriptInfo.get_ScriptBlock() in D:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\ExternalScriptInfo.cs:line 224\r\n at System.Management.Automation.CommandDiscovery.CreateCommandProcessorForScript(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean useNewScope, SessionStateInternal sessionState) in\r\nD:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\CommandDiscovery.cs:line 660\r\n at System.Management.Automation.CommandDiscovery.CreateScriptProcessorForSingleShell(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean useLocalScope, SessionStateInternal sessionState) in\r\nD:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\CommandDiscovery.cs:line 340\r\n at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(CommandInfo commandInfo, CommandOrigin commandOrigin, Nullable`1 useLocalScope, SessionStateInternal sessionState) in\r\nD:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\CommandDiscovery.cs:line 584\r\n at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource) in D:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\ExecutionContext.cs:line 666\r\n at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext\r\ncontext) in D:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\runtime\\Operations\\MiscOps.cs:line 311\r\n at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][]\r\ncommandRedirections, FunctionContext funcContext) in D:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\runtime\\Operations\\MiscOps.cs:line 510\r\n at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame) in\r\nD:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\interpreter\\CallInstruction.Generated.cs:line 608\r\n at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) in\r\nD:\\DEVELOPMENT\\PowerShellCore\\src\\System.Management.Automation\\engine\\interpreter\\ControlFlowInstructions.cs:line 341\r\nCategoryInfo : ParserError: (:) [], ParseException\r\nFullyQualifiedErrorId : EndSquareBracketExpectedAtEndOfType\r\nInvocationInfo :\r\n ScriptLineNumber : 6\r\n OffsetInLine : 11\r\n HistoryId : -1\r\n ScriptName : D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1\r\n Line : [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n\r\n PositionMessage : At D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1:6 char:11\r\n + [Array]::IndexOf($_.IPAddress, $_.IPAddress[0])\r\n + ~\r\n PSScriptRoot : D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\r\n PSCommandPath : D:\\Users\\Bukem\\Documents\\PowerShell\\SCRIPTS\\Test.ps1\r\n CommandOrigin : Internal\r\nScriptStackTrace : at \u003cScriptBlock\u003e, \u003cNo file\u003e: line 1\r\n```\r\n\r\n\r\n### Environment data\r\n\r\n```powershell\r\nName Value\r\n---- -----\r\nPSVersion 7.3.0-preview.1\r\nPSEdition Core\r\nGitCommitId 7.3.0-preview.1-56-g30eac0a11e3479cf4feac76c7fa4b8d621eaabe2\r\nOS Microsoft Windows 10.0.19044\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\nEnabled experimental features:\r\n```powershell\r\nGet-ExperimentalFeature | Select-Object Name, Enabled\r\n\r\nName Enabled\r\n---- -------\r\nPSAMSIMethodInvocationLogging False\r\nPSAnsiRenderingFileInfo False\r\nPSCleanBlock True\r\nPSCommandNotFoundSuggestion False\r\nPSExec False\r\nPSLoadAssemblyFromNativeCode True\r\nPSNativeCommandArgumentPassing True\r\nPSNativeCommandErrorActionPreference True\r\nPSNativePSPathResolution True\r\nPSRemotingSSHTransportErrorHandling True\r\nPSStrictModeAssignment True\r\nPSSubsystemPluginModel True\r\nPSDesiredStateConfiguration.InvokeDscResource True\r\n```\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/kborowinski","@type":"Person","name":"kborowinski"},"datePublished":"2022-02-11T08:58:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/16870/PowerShell/issues/16870"}
| 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:1c77d279-b570-11f7-0110-0f5b10a6818d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C87A:A72D1:E6389E:13A36B9:6A5567AD |
| html-safe-nonce | 630dbde0c3c4537cf200a03e900da9dfb516e733df4537cdfa08b84385cc91e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODdBOkE3MkQxOkU2Mzg5RToxM0EzNkI5OjZBNTU2N0FEIiwidmlzaXRvcl9pZCI6Ijk2NTA3NTgyMDMwMDU2MDMwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | edc915e76a5264c74fa4dd8978827cb26729abd35f2c31446118466e93626041 |
| hovercard-subject-tag | issue:1132122903 |
| 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/16870/issue_layout |
| twitter:image | https://opengraph.githubassets.com/616570b79b82a6fee67badbb8da7132a61e8e9c63f3c2d60797d9d7a5a03bb4f/PowerShell/PowerShell/issues/16870 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/616570b79b82a6fee67badbb8da7132a61e8e9c63f3c2d60797d9d7a5a03bb4f/PowerShell/PowerShell/issues/16870 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kborowinski |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 8201d0b7bc32164c4662de52242e463a356df543 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width