Skip to content

Add explicit discriminants to all enums in #[ast] macro #123

@overlookmotel

Description

@overlookmotel

oxc-project/oxc#4614 made all AST types #[repr(C)]. To complete the work of making everything about the AST's in-memory representation predictable and guaranteed, we need to add explicit discriminants to all enums.

We can do this in the #[ast] macro rather than writing them out by hand. I think we can consider enum discriminants as an internal implementation detail, which does not need to be visible from reading the type defs. The discriminants we set will be the same as Rust compiler would set anyway.

e.g.:

#[ast]
pub enum PropertyKind {
    Init = 0,
    Get = 1,
    Set = 2,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-astArea - AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions