You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ dart --null-safety --enable-experiment=non-nullable temp.dart
ok
But analyzer does not like it:
$ dartanalyzer --enable-experiment=non-nullable temp.dart
Analyzing temp.dart...
error • A nullable type can't be used in an 'on' clause because it isn't valid to throw 'null'. • temp.dart:4:8 • nullable_type_in_catch_clause
1 error found.
I don't see anything in the NNBD spec related to catching non-nullable types so I don't know which tool is behavior correctly. My hunch is that we probably do want to treat dynamic specially and allow that in a catch clause even though it's technically nullable?
The type of the on clause may be nullable. We discussed this here with the decision to allow it. The spec was landed here in that state, but an interim draft specified an error for potentially nullable on clauses, which is perhaps where the analyzer error originates.
As I was migrating language_2/exception/try_catch_optimized5_test.dart, I ran into an interesting failure. Given:
It runs fine in the VM:
But analyzer does not like it:
I don't see anything in the NNBD spec related to catching non-nullable types so I don't know which tool is behavior correctly. My hunch is that we probably do want to treat dynamic specially and allow that in a catch clause even though it's technically nullable?
A related question is around type parameters:
Analyzer currently considers that an error, but does allow:
cc @stereotype441 @scheglov @johnniwinther
The text was updated successfully, but these errors were encountered: