Skip to content

Support selector attribute for ordinary unions #70

Description

@michaelsproul

While adding compatible unions (#67) we've added a selector attribute that allows the union selector to be manually specified. However we haven't yet added selector support for ordinary unions. The reason being that ordinary union support is not needed for the implementation of compatible unions, and it's slightly non-trivial to decide how to combine automatic selector allocation with manual specification, e.g. what does this do?

#[derive(Encode)]
#[ssz(enum_behaviour = "union")]
enum Union {
    #[ssz(selector = "1")]
    A(A),
    B(B),
}

Is it A=1, B=0? or A=1, B=1 and an error?

Or maybe we should say that if any selectors are manually specified then all must be (I think I like this the most).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions