Sdk: "Convert into block body" adds unnecessary `return` before a `throw`

Created on 2 Jan 2018  Â·  2Comments  Â·  Source: dart-lang/sdk

Given

void foo() => throw 'bad';

Place the cursor on the => and run the assist "Convert into block body".
I expected

void foo() {
  throw 'bad';
}

I got

void foo() {
  return throw 'bad';
}

What is the type of a throw expression? Apparently it does not show up as isVoid?
https://github.com/dart-lang/sdk/blob/706d3382edf7d0292324d3f04f4f0472410ed604/pkg/analysis_server/lib/src/services/correction/assist_internal.dart#L707

P2 analyzer-server area-analyzer type-bug

Most helpful comment

All 2 comments

What is the type of a throw expression?

According to the specification:

The static type of a throw expression is ⊥.

Looks like this condition needs to check for bottom.

Was this page helpful?
0 / 5 - 0 ratings