-
Notifications
You must be signed in to change notification settings - Fork 214
Allow ==
on Enum values in const expressions.
#312
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
Comments
Is anything being done about this? It seems like a pretty basic language feature, especially considering how weak Dart's enums already are. |
@Hixie looks like you opened dart-lang/sdk#29278 originally; do you still believe this would be a solid improvement? |
I think this is table stakes. I think we should go much, much further and allow all code in const expressions except code that ends up having side-effects (e.g. opening sockets, printing to stdout, accessing the filesystem, that kind of thing). |
@mit-mit Why wouldn't it be? Enums are already constant-like structures, and using static class members is just a lot of boilerplate code for such a simple thing... |
I'm not saying it isn't, just asking for input. |
@mit-mit Hi! I'd like to say what I think and am trying to do and would like your feedback on the topic. I have a list of type of working hours, being 4: hflex, hnor, hnot, henor. Today we can write with a class for const expressions:
with enums, I'd like to write like this: Furthermore, I'd like enums to be even more flexible, first with value setting for ints only: and being even more flexible, enumeration with another enums: This would allow loop in WorkType.values() without the concern of getting groups instead of single enum values. This would help A LOT coding flags. Of course, all of this is already possible with classes, but it is a lot more code and doesn't really quite match. |
* Add support for using devices (and tested) * Also added Tattle since with othersClank support it was simple. * Re-ordered CardType definitions to have cost last. I attempted to add a compile time assert for set == CardSet.starter || (skillCost > 0 || swordsCost >0), but ran into dart-lang/language#312
This feature could be expected to be available in Dart already: An instance of an |
Closing as duplicate of #1811. |
Confirm that const enum equality works with the addition of enum comparisons in recent language changes like dart-lang/language#312 We can keep an extra test in the suite. Fixes #45441 Bug: #45441 Change-Id: I80f7496e172a9a09e9bec3ea1643811788b38443 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316701 Commit-Queue: Kallen Tu <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
As reported in:
The specification does not allow
==
to be used on enum values in const contexts. This seems reasonable to allow, customers have asked for it, and it should be an easy change to make.Example from dart-lang/sdk#26980
The text was updated successfully, but these errors were encountered: