File tree Expand file tree Collapse file tree 4 files changed +108
-0
lines changed Expand file tree Collapse file tree 4 files changed +108
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, 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
+ /// @assertion - Shortcut and: If `N` is a shortcut "and" expression of the form
6
+ /// `E1 && E2` , then:
7
+ /// - Let `before(E1) = before(N)` .
8
+ /// - Let `before(E2) = split(true(E1))` .
9
+ /// - Let `true(N) = unsplit(true(E2))` .
10
+ /// - Let `false(N) = merge(split(false(E1)), false(E2))` .
11
+ ///
12
+ /// @description Checks that in an expression of the form `E1 && E2` , if `E1` is
13
+ /// `false` and the static type of `E2` is `Never` , then the code after
14
+ /// `E1 && E2` is not considered dead code.
15
+
16
+
17
+ Never foo () => throw "Never" ;
18
+
19
+ main () {
20
+ late int i;
21
+ if (2 > 1 ) {
22
+ false && foo ();
23
+ i = 42 ;
24
+ }
25
+ i; // Not definitely unassigned
26
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, 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
+ /// @assertion - Shortcut and: If `N` is a shortcut "and" expression of the form
6
+ /// `E1 && E2` , then:
7
+ /// - Let `before(E1) = before(N)` .
8
+ /// - Let `before(E2) = split(true(E1))` .
9
+ /// - Let `true(N) = unsplit(true(E2))` .
10
+ /// - Let `false(N) = merge(split(false(E1)), false(E2))` .
11
+ ///
12
+ /// @description Checks that in an expression of the form `E1 && E2` if `E1` is
13
+ /// `true` then `E2` is always executed.
14
+
15
+
16
+ Never foo () => throw "Never" ;
17
+
18
+ main () {
19
+ late int i;
20
+ if (1 > 2 ) {
21
+ true && foo ();
22
+ i = 42 ;
23
+ }
24
+ i; // Definitely unassigned
25
+ //^
26
+ // [analyzer] unspecified
27
+ // [cfe] unspecified
28
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, 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
+ /// @assertion - Shortcut or: If `N` is a shortcut "or" expression of the form
6
+ /// `E1 || E2` , then:
7
+ /// - Let `before(E1) = before(N)` .
8
+ /// - Let `before(E2) = split(false(E1))` .
9
+ /// - Let `false(N) = unsplit(false(E2))` .
10
+ /// - Let `true(N) = merge(split(true(E1)), true(E2))` .
11
+ ///
12
+ /// @description Checks that in an expression of the form `E1 || E2` , if `E1` is
13
+ /// `true` and the static type of `E2` is `Never` , then the code after
14
+ /// `E1 || E2` is not considered dead code.
15
+
16
+
17
+ Never foo () => throw "Never" ;
18
+
19
+ main () {
20
+ late int i;
21
+ if (2 > 1 ) {
22
+ true || foo ();
23
+ i = 42 ;
24
+ }
25
+ i; // Not definitely unassigned
26
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, 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
+ /// @assertion - Shortcut or: If `N` is a shortcut "or" expression of the form
6
+ /// `E1 || E2` , then:
7
+ /// - Let `before(E1) = before(N)` .
8
+ /// - Let `before(E2) = split(false(E1))` .
9
+ /// - Let `false(N) = unsplit(false(E2))` .
10
+ /// - Let `true(N) = merge(split(true(E1)), true(E2))` .
11
+ ///
12
+ /// @description Checks that in an expression of the form `E1 || E2` if `E1` is
13
+ /// `false` then `E2` is always executed.
14
+
15
+
16
+ Never foo () => throw "Never" ;
17
+
18
+ main () {
19
+ late int i;
20
+ if (1 > 2 ) {
21
+ false || foo ();
22
+ i = 42 ;
23
+ }
24
+ i; // Definitely unassigned
25
+ //^
26
+ // [analyzer] unspecified
27
+ // [cfe] unspecified
28
+ }
You can’t perform that action at this time.
0 commit comments