最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dart - Very strange message when analyzing the source code - Stack Overflow

programmeradmin2浏览0评论

Very strange message when analyzing the source code.

int? x;
if (x == null) {
  //
}
The operand can't be null, so the condition is always 'true'.
Remove the condition.dartunnecessary_null_comparison

Yes, the condition is always 'true'.
But the operand can't be anything other than a null.
The operand can't be null is not true.

Or am I somehow perceiving this incorrectly?

Very strange message when analyzing the source code.

int? x;
if (x == null) {
  //
}
The operand can't be null, so the condition is always 'true'.
Remove the condition.dartunnecessary_null_comparison

Yes, the condition is always 'true'.
But the operand can't be anything other than a null.
The operand can't be null is not true.

Or am I somehow perceiving this incorrectly?

Share Improve this question asked Feb 7 at 7:29 mezonimezoni 11.2k4 gold badges37 silver badges57 bronze badges 1
  • Could you mention the Dart version as well? With Dart SDK version: 3.6.2 (stable) I get: The operand must be 'null', so the condition is always 'true'. – Dan R Commented Feb 7 at 11:36
Add a comment  | 

1 Answer 1

Reset to default 2

This is a known issue with the error message, that hasn't been fixed. It should say something like "is always null" instead of "can't be null" for this kind of case.

发布评论

评论列表(0)

  1. 暂无评论