-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
NNBDIssues related to NNBD ReleaseIssues related to NNBD Releasearea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dart2js
Description
The code below is valid NNBD code, and is accepted by the VM, DDC, and the analyzer, but is rejected by dart2js:
leafp-macbookpro:analyzer leafp$ ~/src/dart-repo/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dartanalyzer --enable-experiment=non-nullable ~/tmp/test.dart
Analyzing /Users/leafp/tmp/test.dart...
hint • The return type of 'main' cannot be inferred. • /Users/leafp/tmp/test.dart:4:1 • inference_failure_on_function_return_type
1 hint found.
leafp-macbookpro:analyzer leafp$ ~/src/dart-repo/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dartdevc --enable-experiment=non-nullable -o out.js ~/tmp/test.dart
leafp-macbookpro:analyzer leafp$ ~/src/dart-repo/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dart --enable-experiment=non-nullable ~/tmp/test.dart
leafp-macbookpro:analyzer leafp$ ~/src/dart-repo/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dart2js --enable-experiment=non-nullable ~/tmp/test.dart
../../../../../tmp/test.dart:6:3:
Error: 'case' expressions do not all have type 'E'.
switch (e) {
^
../../../../../tmp/test.dart:7:12:
Info: 'case' expression of type 'E'.
case E.A:
^
../../../../../tmp/test.dart:11:10:
Info: 'case' expression of type 'Null'.
case null:
^
Error: Compilation failed.
enum E {
A,
B}
main() {
E? e = null;
switch (e) {
case E.A:
return;
case E.B:
return;
case null:
return;
}
}
cc @yjbanov
yjbanov
Metadata
Metadata
Assignees
Labels
NNBDIssues related to NNBD ReleaseIssues related to NNBD Releasearea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dart2js