Open
Description
The following code triggers prefer_const_constructors_in_immutables
on A
constructor but it shouldn't as enum comparisons are not yet allowed in asserts.
enum E { a, b }
@immutable
class A {
A([E e = E.b]) : assert(e != E.a); // LINT is here but it shouldn't trigger
}
It looks related to const evaluation as there's no analyzer error on the constructor if we make the constructor const though there's an error on the constructor invocation.
enum E { a, b }
@immutable
class A {
const A([E e = E.b]) : assert(e != E.a); // no diagnostic but there should be an `invalid_constant` error for `e != E.a`
}
void main() {
const A(); // const_evaluation_throws_exception
}
Filed also #45441
/cc @scheglov @bwilkerson
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
prefer_const_constructors_in_immutables
on class that can never be const constructed #58718