Skip to content

Commit 4517362

Browse files
committed
[cfe] Add test for issue 42459
Closes #42459 Change-Id: I77215b0b6dcdf4cdbfd07796c41478087607359f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155860 Reviewed-by: Dmitry Stefantsov <[email protected]>
1 parent 6ca00d1 commit 4517362

8 files changed

+162
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
test() {
6+
(x) {
7+
if (x) {
8+
return 1;
9+
} else {
10+
return;
11+
}
12+
};
13+
14+
void local(x) {
15+
if (x) {
16+
return print('');
17+
} else {
18+
return;
19+
}
20+
}
21+
}
22+
23+
main() {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
4+
static method test() → dynamic
5+
;
6+
static method main() → dynamic
7+
;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/issue42459.dart:10:7: Error: A value must be explicitly returned from a non-void function.
6+
// return;
7+
// ^
8+
//
9+
import self as self;
10+
import "dart:core" as core;
11+
12+
static method test() → dynamic {
13+
(dynamic x) → core::int? {
14+
if(x as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool) {
15+
return 1;
16+
}
17+
else {
18+
return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42459.dart:10:7: Error: A value must be explicitly returned from a non-void function.
19+
return;
20+
^" in null;
21+
}
22+
};
23+
function local(dynamic x) → void {
24+
if(x as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool) {
25+
return core::print("");
26+
}
27+
else {
28+
return;
29+
}
30+
}
31+
}
32+
static method main() → dynamic {}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/issue42459.dart:10:7: Error: A value must be explicitly returned from a non-void function.
6+
// return;
7+
// ^
8+
//
9+
import self as self;
10+
import "dart:core" as core;
11+
12+
static method test() → dynamic {
13+
(dynamic x) → core::int? {
14+
if(x as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool) {
15+
return 1;
16+
}
17+
else {
18+
return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42459.dart:10:7: Error: A value must be explicitly returned from a non-void function.
19+
return;
20+
^" in null;
21+
}
22+
};
23+
function local(dynamic x) → void {
24+
if(x as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool) {
25+
return core::print("");
26+
}
27+
else {
28+
return;
29+
}
30+
}
31+
}
32+
static method main() → dynamic {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test() {}
2+
main() {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main() {}
2+
test() {}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/issue42459.dart:10:7: Error: A value must be explicitly returned from a non-void function.
6+
// return;
7+
// ^
8+
//
9+
import self as self;
10+
import "dart:core" as core;
11+
12+
static method test() → dynamic {
13+
(dynamic x) → core::int? {
14+
if(x as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool) {
15+
return 1;
16+
}
17+
else {
18+
return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42459.dart:10:7: Error: A value must be explicitly returned from a non-void function.
19+
return;
20+
^" in null;
21+
}
22+
};
23+
function local(dynamic x) → void {
24+
if(x as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool) {
25+
return core::print("");
26+
}
27+
else {
28+
return;
29+
}
30+
}
31+
}
32+
static method main() → dynamic {}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/issue42459.dart:10:7: Error: A value must be explicitly returned from a non-void function.
6+
// return;
7+
// ^
8+
//
9+
import self as self;
10+
import "dart:core" as core;
11+
12+
static method test() → dynamic {
13+
(dynamic x) → core::int? {
14+
if(x as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool) {
15+
return 1;
16+
}
17+
else {
18+
return let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42459.dart:10:7: Error: A value must be explicitly returned from a non-void function.
19+
return;
20+
^" in null;
21+
}
22+
};
23+
function local(dynamic x) → void {
24+
if(x as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool) {
25+
return core::print("");
26+
}
27+
else {
28+
return;
29+
}
30+
}
31+
}
32+
static method main() → dynamic {}

0 commit comments

Comments
 (0)