You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parser bug: using break inside of switch in finally block fails to parse #7267
At line:4 char:8
+ 'bar' {break}
+ ~~~~~
Flow of control cannot leave a Finally block.
At line:5 char:8
+ 'foo' {break}
+ ~~~~~
Flow of control cannot leave a Finally block.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ControlLeavingFinally
Environment data
>$PSVersionTable
Name Value
---------
PSVersion 6.0.0
PSEdition Core
GitCommitId v6.0.0
OS Microsoft Windows 10.0.17692
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I'm pretty sure this is a simple bug. The post-parse checks allow break in "loop statements" but switch isn't a "loop statement" but it is a "labelled statement". Changing the check from "loopstatement" to "labelledstatement" fixes this.
Activity
kvprasoon commentedon Jul 11, 2018
repro in latest preview as well.
BrucePay commentedon Jul 11, 2018
I'm pretty sure this is a simple bug. The post-parse checks allow break in "loop statements" but switch isn't a "loop statement" but it is a "labelled statement". Changing the check from "loopstatement" to "labelledstatement" fixes this.
Fix for PowerShell#7267 - an erroneous parse error is generated when …