Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions TypeSystem/flow-analysis/reachability_A18_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion - Shortcut and: If `N` is a shortcut "and" expression of the form
/// `E1 && E2`, then:
/// - Let `before(E1) = before(N)`.
/// - Let `before(E2) = split(true(E1))`.
/// - Let `true(N) = unsplit(true(E2))`.
/// - Let `false(N) = merge(split(false(E1)), false(E2))`.
///
/// @description Checks that in an expression of the form `E1 && E2` `E1` is
/// always executed.
/// @author sgrekhov22@gmail.com

main() {
int i;
(i = 42) != 42 && false;
i; // Definitely assigned
}
20 changes: 20 additions & 0 deletions TypeSystem/flow-analysis/reachability_A18_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion - Shortcut and: If `N` is a shortcut "and" expression of the form
/// `E1 && E2`, then:
/// - Let `before(E1) = before(N)`.
/// - Let `before(E2) = split(true(E1))`.
/// - Let `true(N) = unsplit(true(E2))`.
/// - Let `false(N) = merge(split(false(E1)), false(E2))`.
///
/// @description Checks that in an expression of the form `E1 && E2` if `E1` is
/// `true` then `E2` is always executed.
/// @author sgrekhov22@gmail.com

main() {
int i;
true && (i = 42) != 42;
i; // Definitely assigned
}
23 changes: 23 additions & 0 deletions TypeSystem/flow-analysis/reachability_A18_t03.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion - Shortcut and: If `N` is a shortcut "and" expression of the form
/// `E1 && E2`, then:
/// - Let `before(E1) = before(N)`.
/// - Let `before(E2) = split(true(E1))`.
/// - Let `true(N) = unsplit(true(E2))`.
/// - Let `false(N) = merge(split(false(E1)), false(E2))`.
///
/// @description Checks that in an expression of the form `E1 && E2` if `E1` is
/// `false` then `E2` is never executed.
/// @author sgrekhov22@gmail.com

main() {
late int i;
false && (i = 42) != 42;
i; // Definitely unassigned
//^
// [analyzer] unspecified
// [cfe] unspecified
}
20 changes: 20 additions & 0 deletions TypeSystem/flow-analysis/reachability_A19_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion - Shortcut or: If `N` is a shortcut "or" expression of the form
/// `E1 || E2`, then:
/// - Let `before(E1) = before(N)`.
/// - Let `before(E2) = split(false(E1))`.
/// - Let `false(N) = unsplit(false(E2))`.
/// - Let `true(N) = merge(split(true(E1)), true(E2))`.
///
/// @description Checks that in an expression of the form `E1 || E2` `E1` is
/// always executed.
/// @author sgrekhov22@gmail.com

main() {
int i;
(i = 42) == 42 || true;
i; // Definitely assigned
}
20 changes: 20 additions & 0 deletions TypeSystem/flow-analysis/reachability_A19_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion - Shortcut or: If `N` is a shortcut "or" expression of the form
/// `E1 || E2`, then:
/// - Let `before(E1) = before(N)`.
/// - Let `before(E2) = split(false(E1))`.
/// - Let `false(N) = unsplit(false(E2))`.
/// - Let `true(N) = merge(split(true(E1)), true(E2))`.
///
/// @description Checks that in an expression of the form `E1 || E2` if `E1` is
/// `false` then `E2` is always executed.
/// @author sgrekhov22@gmail.com

main() {
int i;
false || (i = 42) == 42;
i; // Definitely assigned
}
23 changes: 23 additions & 0 deletions TypeSystem/flow-analysis/reachability_A19_t03.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion - Shortcut or: If `N` is a shortcut "or" expression of the form
/// `E1 || E2`, then:
/// - Let `before(E1) = before(N)`.
/// - Let `before(E2) = split(false(E1))`.
/// - Let `false(N) = unsplit(false(E2))`.
/// - Let `true(N) = merge(split(true(E1)), true(E2))`.
///
/// @description Checks that in an expression of the form `E1 || E2` if `E1` is
/// `true` then `E2` is never executed.
/// @author sgrekhov22@gmail.com

main() {
late int i;
true || (i = 42) == 42;
i; // Definitely unassigned
//^
// [analyzer] unspecified
// [cfe] unspecified
}
24 changes: 24 additions & 0 deletions TypeSystem/flow-analysis/reachability_A21_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion - Null check operator: If `N` is an expression of the form `E!`,
/// then:
/// - Let `before(E) = before(N)`.
/// - Let `after(E) = promoteToNonNull(E, after(E))`.
///
/// @description Checks that for expression of the form `E!`
/// `after(E) = promoteToNonNull(E, after(E))`.
/// @author sgrekhov22@gmail.com
/// @issue 60114

main() {
int? n = 2 > 1 ? 1 : null;
int i;

n!;
if (n != null) { // ignore: unnecessary_null_comparison
i = 42;
}
i; // Definitely assigned
}