dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.2k stars 1.57k forks source link

Async transformation crashes on some programs with invalid types #41477

Open chloestefantsova opened 4 years ago

chloestefantsova commented 4 years ago

After https://github.com/dart-lang/sdk/commit/e2b6cc93b65511291721ba077056729d797751ea the async transformation started crashing on some programs, for example, the following one:

foo(Foo x) async {
  for (String s in x) {
    await bar(s);
  }
}

Future<void> bar(String s) {
  return new Future.value(s);
}

main() {}

In the program above Foo isn't declared anywhere resulting in an InvalidType.

chloestefantsova commented 4 years ago

/cc @mkustermann

mkustermann commented 4 years ago

Can the CFE not run modular transformations if the library has compile-time errors?

/cc @johnniwinther

johnniwinther commented 4 years ago

There is no inherent problem in running modular transformations despite compile-time errors. The main challenge is that such transformation needs to give semantics to InvalidType and InvalidExpression and similar constructs that arise as a side effect of the errors.

chloestefantsova commented 4 years ago

I have a CL that attempts to remove the crash and also follow the intention behind the recent change: https://dart-review.googlesource.com/c/sdk/+/142995.