Skip to content

NNBD: Dart does not throw a compile error when declare a non-function typedef variable with unacceptable nullable type parameter #42449

@iarkh

Description

@iarkh

Dart VM version: 2.9.0-18.0.dev (dev) (Mon Jun 22 16:07:30 2020 +0200) on "windows_x64"

The following source code example declares a A<num?> variable for typedef A<X extends num>

class C<X> {}
typedef A<X extends num> = C<X?>;

main() {
  A<num?>? aaa = throw "Here is me";
}

Num? is not assignable to num, so compile error should be thrown here. However, dart does not throw it.

Sample output is:

$> dart --enable-experiment=nonfunction-type-aliases,non-nullable test.dart
Unhandled exception:
Here is me
#0 main (file:///D:/DART/sdk/tests/co19/src/LanguageFeatures/Simple-bounds/static/type-aliases/test.dart:5:18)
#1 _startIsolate. (dart:isolate-patch/isolate_patch.dart:301:19)
#2 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Metadata

Metadata

Labels

P1A high priority bug; for example, a single project is unusable or has many test failuresfront-end-missing-errorlanguage-nonfunction-type-aliasesIssues related to non-function type aliaseslegacy-area-front-endLegacy: Use area-dart-model instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions