[draft] serde-generate / solidity: allow non-contiguous enum variant indices#98
Draft
ma2bd wants to merge 8 commits into
Draft
[draft] serde-generate / solidity: allow non-contiguous enum variant indices#98ma2bd wants to merge 8 commits into
ma2bd wants to merge 8 commits into
Conversation
… Serde index, with precomputed hex discriminants. This also fixes a latent SimpleEnum bug: the previous path emitted the discriminant as a single byte and produced wrong BCS for indices >=128 (SimpleEnum now routes through the same ULEB128 helper as the complex Enum path).
…ncode variant indices, not just length prefixes.
…ant carries a payload (sparse all-Unit or >256-variant all-Unit enums), with a regression test.
…Write in hex_literal to avoid per-byte allocation.
…ip test, exercising the multi-byte ULEB128 indices the old single-byte codec silently mishandled.
…rect integer-to-enum cast (guarded by a range check to defeat uint8 truncation), shrinking bytecode from O(N) branches to a constant.
…etter, guaranteeing user-supplied names cannot collide with generated lowercase prefixes (offset_, seq_, opt_, ...) in function names; covered by a should_panic test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Although the derive macros of Serde always generate contiguous variant indices, it could be desirable to relax this constraint in some cases (see linera-io/linera-protocol#6309).
Test Plan
CI