Open overlookmotel opened 2 months ago
Just to clarify, I mean that #[ast]
macro will add the discriminants:
Type def in js.rs
:
#[ast]
pub enum PropertyKind {
Init,
Get,
Set,
}
after #[ast]
macro expansion:
#[repr(u8)]
pub enum PropertyKind {
Init = 0,
Get = 1,
Set = 2,
}
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.: