-
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 requestarea-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.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
This issue was originally filed by bslesinsk...@gmail.com
The following code is wrong, but looks right. No warning is reported at compile time and no error happens at runtime:
String findFirstError(Map m) {
m.forEach((k,v) {
if (!validate(k,v)) {
return "found a problem with ${k}";
}
});
return "ok";
}
By analogy with regular for loops this looks like it should return early when it finds the first error, but actually the return value from the callback is ignored, so it always returns "ok".
It seems like we should be able to infer that the callback's return type is void, and therefore any return statements within the callback should not return a value.
Stargator
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-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.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug