Skip to content

Incorrect prefer_is_empty warning #58189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spkersten opened this issue Jun 16, 2020 · 2 comments
Closed

Incorrect prefer_is_empty warning #58189

spkersten opened this issue Jun 16, 2020 · 2 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead.

Comments

@spkersten
Copy link
Contributor

Consider:

class Foo {
  const Foo(List<int> numbers)
      : assert(numbers.length > 0),
        assert(numbers.isNotEmpty);
}

The first assert results in a warning say:

info: Use isNotEmpty instead of length (prefer_is_empty at [...] ...)

But following that suggestion (the second assert) is an error:

error: Invalid constant value. (invalid_constant at [...] ...)

Dart 2.7.0

@mraleph mraleph transferred this issue from dart-lang/sdk Jun 16, 2020
@srawlins
Copy link
Member

Thanks for opening!

@bruno-garcia
Copy link
Contributor

bruno-garcia commented Aug 6, 2020

This came up in #57805
I believe it was fixed through dart-archive/linter#2122 and landed in master June 2nd and is on the release notes of 0.1.117

~I'm on Dart version 2.9.0 (build 2.9.0-21.10.beta) and still affected by this issue. ~

Not sure how the linter release gets through into Dart to check versions

Actually my VS Code integration wasn't on 2.9.0 but 2.8.0 instead which didn't have the fix.

I can confirm it's fixed with Dart 2.9.0 and this issue can be closed.

@pq pq closed this as completed Sep 24, 2020
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead.
Projects
None yet
Development

No branches or pull requests

5 participants