3e0d13bc28
If an error happens during the compilation of a function body, an Error is thrown which can be intercepted, and ensures that finally blocks are executed before the isolate is terminated. The language spec is vague about compilation errors. A doc describing the intentions behind this CL is at https://docs.google.com/document/d/1_MWOgwJadLCQSBps0zD6Rj5dG4iP1UBuiDvTMH-WMzI/edit# Example: 1 void bad() { 2 return 5 3 } 4 5 void main(args) { 6 bad(); 7 } Before this CL: $ dart ~/tmp/e.dart 'file:///Users/hausner/tmp/e.dart': error: line 2 pos 11: semicolon expected return 5 ^ $ After this change: $ dart ~/tmp/e.dart Unhandled exception: 'file:///Users/hausner/tmp/e.dart': error: line 2 pos 11: semicolon expected return 5 ^ #0 main (file:///Users/hausner/tmp/e.dart:6:3) #1 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:259) #2 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148) $ Notice that the stack trace points to the call site of bad(), not the text location of the syntax error. That's not a bug. The location of the syntax error is given in the error message. BUG= https://github.com/dart-lang/sdk/issues/23684 R=asiva@google.com, lrn@google.com Review URL: https://codereview.chromium.org/2044753002 .