-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestanalyzer-recoveryarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.contributions-welcomeContributions welcome to help resolve this (the resolution is expected to be clear from the issue)Contributions welcome to help resolve this (the resolution is expected to be clear from the issue)devexp-uxtype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
bool confusing(Object b) {
return b is int // Dart analyzer says: missing selector such as '.identifier' or '[0]' - line 2
&& b = 2; // error is actually here - this should be `==`.
}
void main() {}
Reproduces in dartpad and in IDE. I'd expect to only see an error on line 3 (invalid assignment). I actually see an error on line 2 (in comment), followed by a couple more confusing messages on line 3 :
error
A value of type 'int can't be returned from function 'confusing' because it has a return type of 'bool' - line 2
error
Missing selector such as '.identifier' or '[0]' - line 2
error
The operands of the '&&' operator must be assignable to 'bool' - line 3
error
A value of type 'int' can't be assigned to a variable of type 'bool' - line 3
zeppelin-tt
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestanalyzer-recoveryarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.contributions-welcomeContributions welcome to help resolve this (the resolution is expected to be clear from the issue)Contributions welcome to help resolve this (the resolution is expected to be clear from the issue)devexp-uxtype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
dnfield commentedon Jan 22, 2020
The compiler gives a more sensible error, at least for app-jit snapshots:
MichaelRFairhurst commentedon Jan 22, 2020
Seems like a very reasonable request. This is a common pattern in other languages and should prob give better output here.
@brianwilkerson
jensjoha commentedon Aug 20, 2021
As indicated in a comment above the CFE gives this error message:
This seems like an analyzer bug to me (which the title also says) so I'll but the "old labels" back.
srawlins commentedon Jun 7, 2024
The errors remain today. Very strange errors.