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

A way to require enum variant index being specified #666

Open
nazar-pc opened this issue Dec 14, 2024 · 2 comments
Open

A way to require enum variant index being specified #666

nazar-pc opened this issue Dec 14, 2024 · 2 comments

Comments

@nazar-pc
Copy link
Contributor

I think it would be valuable to make an enum variant index required in derived code.

The way to approach this might be to have a separate feature that would generate a compile-time warning when #[codec(index = something)] is missing.

This is important in blockchain environment where some data structures can evolve over time and refactoring can accidentally break things.

@gui1117
Copy link
Contributor

gui1117 commented Dec 30, 2024

A crate feature might not work, because features get merged. So if a crate A use scale-codec without this feature and B use A and scale-codec with the feature then A won't compile no?

Maybe a new optional attribute: codec::ensure_explicit_indices or codec::disallow_implicit_indices.

@nazar-pc
Copy link
Contributor Author

It will if done the way I suggest: by generating compile-time warning. Dependencies will compile just fine with warnings or not, but anything in crate/workspace will refuse to compile if warnings are denied in the project.

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

No branches or pull requests

2 participants