Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix break inside of for loops that use next (#1436)#1441

Open
ktegan wants to merge 2 commits into
hsutter:main from
ktegan:kegan-1436-break-in-for-loop
Open

fix break inside of for loops that use next (#1436) #1441
ktegan wants to merge 2 commits into
hsutter:main from
ktegan:kegan-1436-break-in-for-loop

Conversation

@ktegan

@ktegan ktegan commented Nov 29, 2025

Copy link
Copy Markdown

This provides a simple solution to issue #1436 based on a the following comment "break" won't [work] until we do extra work to implement that using a flag and implementing "break" as "_for_break = true; continue;.

This would need code review because: there may be more elegant ways to do this, there are some details I'm not sure about (can print_cpp2() replace an emit() call?), and more testing for correctness would need to be done.

I think my biggest question is whether we should follow what the comment suggests or use an alternative approach where we define a default label for every loop and when there is a break that does not include a label add the label of the innermost loop to that break statement. If we used this labeled break solution the generated cpp1 code would use CPP2_CONTINUE_BREAK() to produce a goto statement instead of the solution in this PR which adds a variable and may require a comparison (check if _for_break is true) on every iteration through the loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /