Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow event name collisions within single macro invocation #107

Closed
encody opened this issue Dec 7, 2022 · 0 comments · Fixed by #108
Closed

Disallow event name collisions within single macro invocation #107

encody opened this issue Dec 7, 2022 · 0 comments · Fixed by #108

Comments

@encody
Copy link
Contributor

encody commented Dec 7, 2022

#[event(standard = "x-name-collision", version = "1.0.0")]
enum NameCollision {
    First,
    #[nep297(name = "first")]
    Second,
}

println!("{}", NameCollision::First.to_event_string());
println!("{}", NameCollision::Second.to_event_string());

Output:

EVENT_JSON:{"standard":"x-name-collision","version":"1.0.0","event":"first","data":null}
EVENT_JSON:{"standard":"x-name-collision","version":"1.0.0","event":"first","data":null}

Though this technically has a "valid" use-case (wherein a single event's data can take multiple forms), it is almost always better to use another enum for the metadata type instead of having two events using the same name.

This issue is resolved when the above code produces a compiler error. Obviously it is much more difficult to make separate macro invocations produce a compiler error together, even if they are using the same standard field value.

@encody encody linked a pull request Dec 15, 2022 that will close this issue
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 a pull request may close this issue.

1 participant