dart-lang / dart-lang/language
Default argument values should imply "const" context
Open
enhanced-const
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
If you run this:
```
class Test {
Test({ this.test = Duration(minutes: 1) }); // the default value is not explicitly "const"
final Duration test;
}
void main() {
Test();
}
```
...you get an exception (a bad one, currently, see https://github.com/dart-lang/sdk/issues/35683).
I think the fact that only a constant is allowed to be used there should imply a constant context and thus make the "const" redundant and implied.
Contributor guide
Assessment
This issue has not been assessed yet.