Open JaffaKetchup opened 4 months ago
Would appriciate a triage :) No rush ofc. Kinda feels similar to #4871 (an expression that should be wrapped with brackets in an unexpected place).
I'm not sure why no one is triaging this repo. But I threw some labels on.
Here's another interesting example. The code could remain legal when removing the parens, if we're not looking at an expression-statement. For example:
Future<void> invalid(Object v) {
return switch (v) { _ => Future.value() }.then((_) {});
}
This is legal code. However, I think it might be surprising that parentheses aren't required around the switch expression, so I think they should be allowed, even if it doesn't cause a parse error.
I'm surprised that that is legal but the version without return isn't. I guess the answers can be found in the language definition, but I agree that does seem like a case where you might want to allow unnecessary brackets.
Describe the issue When using a switch expression that is immediately followed by a method on the return result (such as
.then
when the expression returnsFuture
s, parenthesis are required, but the linter creates a false positive.To Reproduce
Expected behavior The lint should not be thrown