Open eernstg opened 12 months ago
It's worth mentioning that this cannot affect constant evaluation, since constant ==
is only allowed with primitive equality, not anything that calls a user written implementation. So it will only be incorrect typing of code that will never be executed at that type. (So technically it's not "unsound", there is no expression which is evaluated to a type which isn't a subtype of its static type. It's just not correct, it doesn't match the compiler behavior.)
Well, it's an analyzer issue. If the CFE had had the same static analysis then it would certainly have been a soundness issue: It will attempt to call toRadixString
on true
.
@srawlins, I just tried the example, and it looks like it has been resolved already?
Consider the following example, based on this comment:
This shows that it is unsound to assume that the type of an
<equalityExpression>
isNever
, even in the case where the corresponding declaration ofoperator ==
has return typeNever
. Equality expressions should always have the typebool
.However, the analyzer (DartPad based on Dart SDK 3.3.0-16.0.dev) does not report any errors on the line marked 'Unsound', which implies that it considers
neverEqual == other
to be an expression that cannot complete normally.