Skip to content

Conversation

@paradoxicalguy
Copy link

enums with named fields are currently laid out positionally, which can
pair unrelated fields across variants and cause unsound behavior.

this PR explicitly rejects named-field enums in the SoAble derive macro,
emitting a clear compile-time error explaining that a field-name–based layout is required.

this avoids unsoundness while leaving room for a correct implementation in the future.

fixes #43 by rejecting the problematic case.

Copy link
Member

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

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

I'd rather see the named field cases fixed than to remove the support; right now they work and are generally fine in normal cases when the user has laid them out in systematic order.

Also thank you for the contribution and hello! :)

@paradoxicalguy
Copy link
Author

hello :) and thank you for the clarification

i'll take a look at implementing a correct field-name-based mapping for enums with named fields (so that fields are paired by name rather than position) and update the PR accordingly.

@paradoxicalguy
Copy link
Author

i’ve updated the derive to implement a field-name–based SoA layout for enums with named fields, pairing fields by name rather than by position.
all tests passed; would appreciate another look!

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.

Named enum fields are not named

2 participants