Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Issue 2044753002: Make compile-time errors catchable (Closed)

Created:
4 years, 6 months ago by hausner
Modified:
4 years, 3 months ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org, Lasse Reichstein Nielsen, floitsch, rmacnak
Base URL:
git@github.com:dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Make compile-time errors catchable 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 Committed: https://github.com/dart-lang/sdk/commit/3e0d13bc287cc89ebc15969376a90bd7f67bef6a

Patch Set 1 #

Patch Set 2 : wip #

Total comments: 6

Patch Set 3 : Make SyntaxError a private class #

Patch Set 4 : Address review comments #

Patch Set 5 : Make precompiler work with new error class #

Total comments: 2

Patch Set 6 : Address review comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+62 lines, -5 lines) Patch
M runtime/lib/errors_patch.dart View 1 2 1 chunk +7 lines, -0 lines 0 comments Download
M runtime/vm/clustered_snapshot.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/compiler.cc View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 3 4 5 2 chunks +16 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl_test.cc View 1 3 chunks +0 lines, -3 lines 0 comments Download
M runtime/vm/exceptions.h View 1 2 3 chunks +3 lines, -0 lines 0 comments Download
M runtime/vm/exceptions.cc View 1 2 3 4 5 2 chunks +12 lines, -0 lines 0 comments Download
M runtime/vm/object.h View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M runtime/vm/object_store.h View 1 2 2 chunks +8 lines, -0 lines 0 comments Download
M runtime/vm/object_store.cc View 1 2 2 chunks +6 lines, -0 lines 0 comments Download
M runtime/vm/precompiler.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/raw_object.h View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/symbols.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 16 (8 generated)
Lasse Reichstein Nielsen
> Dart2js needs to be changed accordingly so the platforms match. I don't think dart2js ...
4 years, 5 months ago (2016-07-22 11:46:03 UTC) #2
hausner
4 years, 3 months ago (2016-09-14 22:33:06 UTC) #5
Lasse Reichstein Nielsen
https://codereview.chromium.org/2044753002/diff/20001/sdk/lib/core/errors.dart File sdk/lib/core/errors.dart (right): https://codereview.chromium.org/2044753002/diff/20001/sdk/lib/core/errors.dart#newcode576 sdk/lib/core/errors.dart:576: class SyntaxError extends Error { I have two objections ...
4 years, 3 months ago (2016-09-15 05:41:35 UTC) #9
siva
maybe change the title from 'Experimental change' to 'Make syntax errors catchable' I tend to ...
4 years, 3 months ago (2016-09-15 18:11:45 UTC) #10
hausner
PTAL. The error class is now vm-only and private. https://codereview.chromium.org/2044753002/diff/20001/runtime/vm/dart_api_impl.cc File runtime/vm/dart_api_impl.cc (right): https://codereview.chromium.org/2044753002/diff/20001/runtime/vm/dart_api_impl.cc#newcode190 runtime/vm/dart_api_impl.cc:190: ...
4 years, 3 months ago (2016-09-15 21:28:29 UTC) #12
siva
still LGTM. https://codereview.chromium.org/2044753002/diff/80001/runtime/vm/dart_api_impl.cc File runtime/vm/dart_api_impl.cc (right): https://codereview.chromium.org/2044753002/diff/80001/runtime/vm/dart_api_impl.cc#newcode195 runtime/vm/dart_api_impl.cc:195: return false; maybe return (obj.GetClassId() == error_class.id());
4 years, 3 months ago (2016-09-16 00:12:09 UTC) #13
Lasse Reichstein Nielsen
lgtm https://codereview.chromium.org/2044753002/diff/80001/runtime/lib/errors_patch.dart File runtime/lib/errors_patch.dart (right): https://codereview.chromium.org/2044753002/diff/80001/runtime/lib/errors_patch.dart#newcode366 runtime/lib/errors_patch.dart:366: String toString() => _errorMsg; If the error messages ...
4 years, 3 months ago (2016-09-16 05:34:29 UTC) #14
hausner
4 years, 3 months ago (2016-09-16 17:10:44 UTC) #16
Message was sent while issue was closed.
Committed patchset #6 (id:100001) manually as
3e0d13bc287cc89ebc15969376a90bd7f67bef6a (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698