You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the upcoming enhanced-enums feature, we can have arguments to constructors in enum value declarations. They are desugared into the right hand side of the declaration of a static const variable, so presumably they'd be in a constant context?
enumE {
v([]); // Means `v(const [])`?constE(_);
}
Currently, the analyzer fails to handle the above declaration because it reports that Enum does not have the required constant constructor (and this means that no enhanced enum declarations will work at all), but the CFE takes the position that it is not a constant context, and hence it is an error to have [] because no implicit addition of const occurs.
I do not see any plausible future development where enum values will accept non-constant constructor arguments, so we might as well make the value declaration terms a constant context.
Aha, I hadn't found that bit in the spec, this means that the fact that it is not treated as a constant context is an issue on implementations: dart-lang/sdk#48232.
With the upcoming enhanced-enums feature, we can have arguments to constructors in enum value declarations. They are desugared into the right hand side of the declaration of a
static const
variable, so presumably they'd be in a constant context?Currently, the analyzer fails to handle the above declaration because it reports that
Enum
does not have the required constant constructor (and this means that no enhanced enum declarations will work at all), but the CFE takes the position that it is not a constant context, and hence it is an error to have[]
because no implicit addition ofconst
occurs.I do not see any plausible future development where enum values will accept non-constant constructor arguments, so we might as well make the value declaration terms a constant context.
@lrhn, @munificent, @leafpetersen, @natebosch, @jakemac53, @stereotype441, WDYT?
The text was updated successfully, but these errors were encountered: