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

Fix compiler crash from match with extra parens around let in tuple #4595

Merged

Conversation

chriskdon
Copy link
Contributor

Fixes #4412

The compiler would crash if an extra set of parens were added to a single element tuple match of a union type. For example, if type Foo is (I32 | (I32, I32)) is being matched, then a match clause like | (123, (let x: I32)) => x would crash the compiler. This was caused by the codegen for the match not handling the extra SEQ node in the AST created by the parens. This change now skips any extra SEQ nodes when performing codegen for tuple matches.

Fixes ponylang#4412

The compiler would crash if an extra set of parens were added to a
single element tuple match of a union type. For example,
if `type Foo is (I32 | (I32, I32))` is being matched, then a match
clause like `| (123, (let x: I32)) => x` would crash the compiler.
This was caused by the codegen for the match not handling the extra
SEQ node in the AST created by the parens. This change now skips
any extra SEQ nodes when performing codegen for tuple matches.
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Jan 23, 2025
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Jan 23, 2025
@ponylang-main
Copy link
Contributor

Hi @chriskdon,

The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 4595.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

Copy link
Member

@SeanTAllen SeanTAllen left a comment

Choose a reason for hiding this comment

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

We have used Pony test as part of any full program tests. I believe what we want to test is that the program compiles and possibly that it did the match correctly.

For that not using pony test is fine. See the other tests that set the exitcode. You can have a regular program like your minimal example and set the exit code to the extracted match value and then include an "expected exit" file and that will work with the runner as it is designed.

let me know if that makes sense, if not, i can supply a suggestion in the PR that would change the test.

@chriskdon
Copy link
Contributor Author

@SeanTAllen thanks for the suggestion. Let me know if you want anything else changed, or the release notes reworded.

@SeanTAllen SeanTAllen changed the title Fix tuple match with extra single element parens Fix compiler crash from match with extra parens around let in tuple Jan 24, 2025
.release-notes/4595.md Outdated Show resolved Hide resolved
@SeanTAllen
Copy link
Member

SeanTAllen commented Jan 24, 2025

thanks @chriskdon.

i can hardly wait for the next PR from you!

😉

@chriskdon
Copy link
Contributor Author

Thanks! I look forward to contributing more in the future. 😀

@SeanTAllen SeanTAllen merged commit f4e94df into ponylang:main Jan 24, 2025
22 checks passed
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Jan 24, 2025
github-actions bot pushed a commit that referenced this pull request Jan 24, 2025
github-actions bot pushed a commit that referenced this pull request Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ponyc segfaults when trying to match using a single element tuple form
3 participants