Analyzer: "assert(list.length > 0)" does not produce an error despite it being one #52833
Labels
analyzer-constants
analyzer-ux
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
P2
A bug or feature request we're likely to work on
This seems like a regression, but I couldn't tell you since when/what version.
$ dart --version Dart SDK Version: 3.0.5 (stable) (Mon Jun 12 18:31:49 2023 +0000) on "macos_arm64"
This cause a constant evaluation error at the call-site
const RequiresNonEmptyList([1])
, but the actual error is never shown by the analyzer - I have to use another tool (such as Dart2JS) to reveal the root cause:I'm guessing there was plans to allow constant evaluations of
<List>.length
but it was never fully implemented or requires some sort of flag/experiments that aren't typically enabled - in either case this is confusing behavior to (statically) allow something that is invalid.For example, if I write
: assert(numbers.isNotEmpty)
, I get (in the analyzer):(Which isn't a great error message, but at least it's shown within the
assert
)The text was updated successfully, but these errors were encountered: