Skip to content
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

There should be an analyzer hint for duplicate keys in a map pattern #50588

Closed
stereotype441 opened this issue Nov 30, 2022 · 2 comments
Closed
Assignees
Labels
analyzer-warning Issues with the analyzer's Warning codes 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 type-enhancement A request for a change that isn't a bug
Milestone

Comments

@stereotype441
Copy link
Member

Similar to the existing hint EQUAL_KEYS_IN_MAP. It would fire for code like this:

f(x) {
  switch (x) {
    case {1.5: var y, 1.5: var z}:
      break;
  }
}

(which has the surprising behaviour of matching a map of length 2 with a key 1.5. See discussion at dart-lang/language#2657.)

@stereotype441 stereotype441 added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Nov 30, 2022
@srawlins srawlins added P1 A high priority bug; for example, a single project is unusable or has many test failures analyzer-warning Issues with the analyzer's Warning codes type-enhancement A request for a change that isn't a bug labels Nov 30, 2022
@srawlins srawlins added this to the Dart 3 stable milestone Nov 30, 2022
@srawlins srawlins added P2 A bug or feature request we're likely to work on and removed P1 A high priority bug; for example, a single project is unusable or has many test failures labels Nov 30, 2022
@srawlins srawlins modified the milestones: Dart 3 stable, Dart 3 beta 3 Nov 30, 2022
@srawlins
Copy link
Member

srawlins commented Mar 2, 2023

CC @scheglov just checking that this is not implemented yet. Not sure if the spec changed etc since November.

@scheglov scheglov self-assigned this Mar 2, 2023
@scheglov
Copy link
Contributor

scheglov commented Mar 2, 2023

The specification says that it is a compile-time error if "Any two keys in the map are identical." It was implemented before, but I'd like to add a more specific unit test. https://dart-review.googlesource.com/c/sdk/+/286522

copybara-service bot pushed a commit that referenced this issue Mar 2, 2023
…le(s).

Bug: #50588
Change-Id: I952d0ec59045c68f63a5f028083cf17c1b633f3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286522
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
@scheglov scheglov closed this as completed Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-warning Issues with the analyzer's Warning codes 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 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants