-
Notifications
You must be signed in to change notification settings - Fork 28
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
are zero field/variant enum/bundle types legal #208
Comments
This is a fair point. Presumably, it should work as a 0-width type. (Just like |
While a Bundle with no fields is a zero-width type, an enumeration would be a zero-width type with one variant. I don't know if firtool implements it either but it's a bit different than |
Ah. I made a mistake here. The bitwidth of a type should be log2 of the number of values it supports. Eg, a So the bitwidth of an empty type (such as an empty enum) should be undefined, as log2(0) is undefined. So yeah. Scratch what I said earlier. |
In Rust, zero-variant enums are generally size zero (though not currently guaranteed). they are types which can not ever have any values of that type, so they're used for code paths that never return (not very applicable to firrtl) or can't happen (somewhat useful in firrtl). e.g. in Rust you can have see docs for that kind of enum would be useful in generic code where you instantiate some generic module that can handle an error, e.g. by propagating the error value to some output, but in your specific use it never will handle an error so supplying an empty enum type as the error type can help by making firrtl automatically remove all error handling code and data. |
afaict the specification doesn't specify if you can have an enumeration type with no variants
{||}
(the grammar allows it, but I'm not sure if that's intentional, since uninhabited types behave very oddly).The specification says you can have a bundle type with no fields but the grammar doesn't allow it:
firrtl-spec/spec.md
Lines 4406 to 4415 in 9b0357e
The text was updated successfully, but these errors were encountered: