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] support const in const #14223

Merged
merged 5 commits into from
Oct 26, 2023
Merged

[move] support const in const #14223

merged 5 commits into from
Oct 26, 2023

Conversation

cgswords
Copy link
Contributor

Description

Support constants in constants.

Test Plan

Added new tests


If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.

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

The error for using const-in-const changed to point at the feature gating.

@vercel
Copy link

vercel bot commented Oct 12, 2023

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

Name Status Preview Comments Updated (UTC)
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 18, 2023 4:56pm
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Oct 18, 2023 4:56pm
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Oct 18, 2023 4:56pm
mysten-ui ⬜️ Ignored (Inspect) Visit Preview Oct 18, 2023 4:56pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Oct 18, 2023 4:56pm

@cgswords cgswords marked this pull request as ready for review October 12, 2023 07:42
@cgswords cgswords changed the title Support const in const [move-2024] support const in const Oct 12, 2023
Copy link
Contributor

@tnowacki tnowacki left a comment

Choose a reason for hiding this comment

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

Overall, looks great!

Thoughts on how difficult this would be to add for public(package) constants (plus adding support for public(package) constants :))

Comment on lines 98 to 100
let name = match e_ {
E::Constant(name) => name,
_ => unreachable!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit, let else might read better here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are several other arms of this match that use a similar let pattern. Should I rewrite them as well?

external-crates/move/move-compiler/src/cfgir/translate.rs Outdated Show resolved Hide resolved
external-crates/move/move-compiler/src/cfgir/translate.rs Outdated Show resolved Hide resolved
external-crates/move/move-compiler/src/cfgir/translate.rs Outdated Show resolved Hide resolved
external-crates/move/move-compiler/src/cfgir/translate.rs Outdated Show resolved Hide resolved
external-crates/move/move-compiler/src/editions/mod.rs Outdated Show resolved Hide resolved
@cgswords cgswords changed the title [move-2024] support const in const [move] support const in const Oct 19, 2023
Copy link
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. A couple small nits.

Could you also add a couple valid tests to make sure constants are actually folded? Currently I'm just seeing the change to the already existing cyclic const test.

Comment on lines 98 to 102
let name = if let E::Constant(name) = e_ {
name
} else {
unreachable!()
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: a perfect use-case for let-else IMO

Suggested change
let name = if let E::Constant(name) = e_ {
name
} else {
unreachable!()
};
let E::Constant(name) = e_ else {
unreachable!()
};

external-crates/move/move-compiler/src/cfgir/translate.rs Outdated Show resolved Hide resolved
@cgswords
Copy link
Contributor Author

cgswords commented Oct 23, 2023

@tzakian I'll fix the nits when I get back to the office, but -- doesn't the transactional test I posted do the correct thing for testing they are actually folded?

@tzakian
Copy link
Contributor

tzakian commented Oct 23, 2023

doesn't the transactional test I posted do the correct thing for testing they are actually folded?

Egads you're totally right. For some reason my eyes just went to the expected value files and errors, and I didn't see those. But yes, those are exactly the correct tests so please disregard :)

Copy link
Contributor

@tnowacki tnowacki left a comment

Choose a reason for hiding this comment

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

Looks good! Just make sure you pick up @tzakian's spelling and style comments :)

Comment on lines +316 to +317
if let Some(mident) = &self.current_module {
self.module_info(mident).package
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, self.current_module.as_ref().map

@cgswords cgswords merged commit b9f12a8 into main Oct 26, 2023
32 checks passed
@cgswords cgswords deleted the cgswords/const_in_const branch October 26, 2023 17:31
jonas-lj pushed a commit to jonas-lj/sui that referenced this pull request Nov 2, 2023
## Description 

Support constants in constants.

## Test Plan 

Added new tests

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

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

- [ ] protocol change
- [x] 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

The error for using const-in-const changed to point at the feature
gating.
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.

3 participants