Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer generating labels in the automaton to prevent duplicate labels being generated #105

Merged
merged 4 commits into from
Nov 8, 2024

Conversation

gafter
Copy link
Member

@gafter gafter commented Nov 7, 2024

The generated code for @match_return and @match_fail produce labels in the generated code. However, the code for patterns may be repeated, and code that contains these constructs is rewritten as part of the pattern. Consequently, these constructs can end up generating code with duplicate labels. To prevent that, we defer generating the label until the code is generated, so each copy of it will get a distinct label.

The first commit makes a couple of changes that are just refactorings to simplify things.
The second commit fixes the bug.
You will probably find it easier to review the two commits separately.

Fixes: #102

@gafter gafter requested a review from nystrom November 7, 2024 19:06
@gafter gafter self-assigned this Nov 7, 2024
@gafter gafter requested a review from mcmcgrath13 November 7, 2024 19:09
src/match_return.jl Outdated Show resolved Hide resolved
Copy link
Collaborator

@nystrom nystrom left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good except for a minor nit.

@gafter gafter merged commit 356d365 into main Nov 8, 2024
7 checks passed
@gafter gafter deleted the bug102 branch November 8, 2024 23:47
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.

Duplicate goto labels generated when using @match_return
2 participants