Skip to content

Pattern variable rejected as not in scope after a labeled block exited via break <label> #5172#5173

Merged
jarthana merged 1 commit into
eclipse-jdt:masterfrom
jarthana:gh5172
Jul 13, 2026
Merged

Pattern variable rejected as not in scope after a labeled block exited via break <label> #5172#5173
jarthana merged 1 commit into
eclipse-jdt:masterfrom
jarthana:gh5172

Conversation

@jarthana

@jarthana jarthana commented Jul 1, 2026

Copy link
Copy Markdown
Member

What it does

Fixes #5172

How to test

Author checklist

@srikanth-sankaran
srikanth-sankaran self-requested a review July 2, 2026 00:49
@srikanth-sankaran

Copy link
Copy Markdown
Contributor

I offer to review after all tests are green.

@jarthana

jarthana commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Srikanth, there are two changes as part of this PR.

  1. The change in LabeledStatement ensures that the variable bindings in scope of a statement (for e.g., while loop) are fetched even when it's wrapped in a labeled statement. This is guarded by a check that tests that the break label is not the same label as that of the labeled statement.
  2. The second change in Statement, visit(...) - Earlier, breaksOut returned true if a null label was passed. But I think that should only be allowed when for a non-labeled break statement.

Note: The comments and some of the code were added by the bot :)

@srikanth-sankaran srikanth-sankaran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please proceed.

@jarthana
jarthana merged commit af8b047 into eclipse-jdt:master Jul 13, 2026
13 checks passed
@jarthana
jarthana deleted the gh5172 branch July 13, 2026 12:17
@jarthana jarthana added this to the 4.41 M2 milestone Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pattern variable rejected as not in scope after a labeled block exited via break <label>

2 participants