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

[move-enums] Add mut in patterns for mutable bindings #15795

Merged
merged 3 commits into from
Feb 5, 2024

Conversation

tzakian
Copy link
Contributor

@tzakian tzakian commented Jan 19, 2024

Description

Adds mut to enum patterns.

  • A mut modifier is required on a variable that is modified on the RHS (same rules as let mut.
  • mut is only allowed in front of variable binders in patterns (and field names if punning in the pattern).
  • Binders across or-patterns must have the same mutability

Test Plan

Added new tests


If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section.

Type of Change (Check all that apply)

  • protocol change
  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • breaking change for validators or node operators (must upgrade binaries)
  • breaking change for on-chain data layout
  • necessitate either a data wipe or data migration

Release notes

@tzakian tzakian requested a review from cgswords January 19, 2024 01:09
Copy link

vercel bot commented Jan 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2024 10:35pm
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2024 10:35pm
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2024 10:35pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Feb 5, 2024 10:35pm
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 5, 2024 10:35pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 5, 2024 10:35pm

Copy link
Contributor

@cgswords cgswords left a comment

Choose a reason for hiding this comment

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

Some smalll nits about error messages, but looks good to me.

A few more tests might be nice, too.

@cgswords cgswords force-pushed the cgswords/compiler_enums branch 3 times, most recently from 7fd460b to 1783e03 Compare January 23, 2024 05:18
@tzakian tzakian requested a review from cgswords January 23, 2024 20:52
tzakian and others added 2 commits February 5, 2024 14:08
## Description 

Add support for ellipsis patterns in both enum and struct patterns. 

Ellipsis patterns are supported in both named and positional patterns.
1. Only one ellipsis pattern may be present (both in positional and
named patterns).
2. An ellipsis pattern corresponds to zero or more arguments.
3. Ellipsis patterns are only valid as field patterns, and cannot occur
as a top-level pattern.

Some examples of valid patterns (for both struct and enum variant
patterns):

```
C(..)
C(x, ..)
C(x, .., y)
C(.., x)

N { x, .. }
N { x, y, .. }
N { .., x }
N { .. }
```

Some invalid patterns:

```
C(.., ..)
C(x, .., y, ..)
C(..) // if C is a named variant or does not have any parameters

N { .., .. }
N { .. } // If N is a positional/empty variant
```

## Test Plan 

Added additional positive and negative tests.

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
@tzakian tzakian requested review from Nikhil-Mysten and hayes-mysten and removed request for a team February 5, 2024 22:30
@github-actions github-actions bot added the Type: Documentation Improvements or additions to documentation label Feb 5, 2024
@tzakian tzakian changed the base branch from cgswords/compiler_enums to cgswords/compiler_enums_no_bytecode February 5, 2024 22:31
@tzakian tzakian merged commit 641500f into cgswords/compiler_enums_no_bytecode Feb 5, 2024
8 checks passed
@tzakian tzakian deleted the tzakian/mut_patterns branch February 5, 2024 22:35
cgswords pushed a commit that referenced this pull request Feb 7, 2024
Adds `mut` to enum patterns.
* A `mut` modifier is required on a variable that is modified on the RHS
(same rules as `let mut`.
* `mut` is only allowed in front of variable binders in patterns (and
field names if punning in the pattern).
* Binders across or-patterns must have the same mutability

Added new tests

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration
cgswords pushed a commit that referenced this pull request Feb 7, 2024
Adds `mut` to enum patterns.
* A `mut` modifier is required on a variable that is modified on the RHS
(same rules as `let mut`.
* `mut` is only allowed in front of variable binders in patterns (and
field names if punning in the pattern).
* Binders across or-patterns must have the same mutability

Added new tests

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants