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

[Refactor] Pattern positions #1819

Merged
merged 1 commit into from
Feb 16, 2024
Merged

[Refactor] Pattern positions #1819

merged 1 commit into from
Feb 16, 2024

Conversation

yannham
Copy link
Member

@yannham yannham commented Feb 14, 2024

Depends on #1817.

Patterns were annotated with a span, which must always be a well-defined location in the source file. The implementation of full pattern matching - i.e. allowing match expression to have arbirary patterns on the left hand side of "=>" - showed that this is an issue, because enum contracts is implemented by generating a match expression, which doesn't have a proper position.

This commit switches to optional positions instead, as is customary for other subterms, delaying the fearful pos.unwrap() to the latest moment possible, when we need to generate a contract and build a Label during a pattern destructuring which shouldn't affect the contract-generated match expressions.

@yannham yannham requested review from jneem and vkleen February 14, 2024 20:27
@github-actions github-actions bot temporarily deployed to pull request February 14, 2024 20:31 Inactive
@yannham yannham mentioned this pull request Feb 14, 2024
5 tasks
@yannham yannham force-pushed the feat/enum-pattern-elaboration branch from a262f73 to 6fdb212 Compare February 16, 2024 07:46
Base automatically changed from feat/enum-pattern-elaboration to master February 16, 2024 08:13
Copy link

dpulls bot commented Feb 16, 2024

🎉 All dependencies have been resolved !

Patterns were annotated with a span, which must always be a well-defined
location in the source file. The implementation of full pattern matching
- i.e. allowing match expression to have arbirary patterns on the left
hand side of "=>" - showed that this is an issue, because the enum
contract is implemented using match, and thus generate a match
expression without a definite position.

This commit switches to optional position instead, delaying the fearful
`pos.unwrap()` to the latest moment possible, when we need to generate a
contract and build a `Label` during a pattern destructuring, which
shouldn't affect the contract-generated match expressions.
@yannham yannham force-pushed the refactor/pattern-positions branch from 2a9448e to 5d2c776 Compare February 16, 2024 08:29
@yannham yannham enabled auto-merge February 16, 2024 08:30
@github-actions github-actions bot temporarily deployed to pull request February 16, 2024 08:33 Inactive
@yannham yannham added this pull request to the merge queue Feb 16, 2024
Merged via the queue into master with commit 0b2f68e Feb 16, 2024
5 checks passed
@yannham yannham deleted the refactor/pattern-positions branch February 16, 2024 08:55
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.

2 participants