dart-lang / dart-lang/language
Switch expression is not exhaustive on integers
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
* Dart 3.0.0
The analyzer claims that the following code snippet isn't exhaustive when it is. It emits the following message: `The type 'int' is not exhaustively matched by the switch cases since it doesn't match 'int()'`.
```dart
void main() {
final foo = switch ('a'.compareTo('b')) {
> 0 => 'more',
== 0 => 'equal',
< 0 => 'less',
};
}
```
Contributor guide
Research direction
No implementation file or test is named. Start by reproducing the Dart 3.0.0 switch expression from the issue and trace the analyzer's exhaustiveness check for relational patterns on int; done means the exhaustive cases no longer produce the reported int() diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100