Closed
Description
Example:
void main() {
const il = <int>[2, 3];
const nl = <num>[2, 3];
const v1 = (il == nl) ? (1 ~/ 0) : 0; // Analyzer error
const v2 = identical(il, nl) ? (1 ~/ 0) : 0;
const iz = <int>{2, 3};
const nz = <num>{2, 3};
const v3 = (iz == nz) ? (1 ~/ 0) : 0; // Analyzer error
const v4 = identical(iz, nz) ? (1 ~/ 0) : 0;
const im = <int, int>{2: 0, 3: 0};
const nm = <num, int>{2: 0, 3: 0};
const v5 = (im == nm) ? (1 ~/ 0) : 0; // Analyzer error
const v6 = identical(im, nm) ? (1 ~/ 0) : 0;
const ic = C<int>(1);
const nc = C<num>(1);
const v7 = (ic == nc) ? (1 ~/ 0) : 0; // Analyzer error
const v8 = identical(ic, nc) ? (1 ~/ 0) : 0;
}
class C<T> {
final T v;
const C(this.v);
}
Here the analyzer considers the constant values equal if they have the same state, but they are not identical, and the types in question do not override Object.operator==
, so equality for those objects is identity.
In every example here, the ==
check should give false.
CFE has no issue.