Fix for #7267 - Allow break inside switch statement clauses in a finally block.#7273
Conversation
…break is used in a switch statment in a finally block
|
Bruce, The method being modified is also used by VisitContinueStatement and VisitReturnStatement, which I believe should still throw the error when present in a switch statement rather than being "fixed" along with Break. |
|
@TimCurwick When it's a For a switch -wildcard ( 'Hello World', 'World' )
{
'*hello*'
{
"process hello in '$_'"
}
'*world*'
{
"process world in '$_'"
}
}
> process hello in 'Hello World'
> process world in 'Hello World'
> process world in 'World'
switch -wildcard ( 'Hello World', 'World' )
{
'*hello*'
{
"process hello in '$_'"
continue
}
'*world*'
{
"process world in '$_'"
}
}
> process hello in 'Hello World'
> process world in 'World' |
|
Ah. Of course. Thank you. Though that does point to a problem with help topic about_Continue, which says, "In a script, the Continue statement immediately returns the program flow to the top of the innermost loop that is controlled by a For, Foreach, or While statement." |
|
@TimCurwick That looks like a doc bug. Can you please open an issue in https://github.com/powershell/powershell-docs? Thank you! |
PR Summary
Fix for #7267. You should be able to use
breakin aswitchstatement in afinallyblock but an erroneous parse error was being generated in this case. The fix is to change the semantic check to allow forbreakin labelled statements rather than only in loop statements.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests