Skip to content

Commit fa9304b

Browse files
authored
#3057. Add pattern assignment cases to while-loop tests (#3127)
1 parent 1ac4e03 commit fa9304b

File tree

2 files changed

+92
-2
lines changed

2 files changed

+92
-2
lines changed

TypeSystem/flow-analysis/reachability_while_A02_t01.dart

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
/// detects assignment in `S`.
1313
/// @author [email protected]
1414
15-
main() {
15+
class C {
16+
int v;
17+
C(this.v);
18+
}
19+
20+
test1() {
1621
try {
1722
late int i;
1823
while (1 > 2) {
@@ -21,3 +26,40 @@ main() {
2126
i; // Not definitely unassigned
2227
} catch (_) {}
2328
}
29+
30+
test2() {
31+
try {
32+
late int i;
33+
while (1 > 2) {
34+
(i,) = (42,);
35+
}
36+
i; // Not definitely unassigned
37+
} catch (_) {}
38+
}
39+
40+
test3() {
41+
try {
42+
late int i;
43+
while (1 > 2) {
44+
(x: i) = (x: 42);
45+
}
46+
i; // Not definitely unassigned
47+
} catch (_) {}
48+
}
49+
50+
test4() {
51+
try {
52+
late int i;
53+
while (1 > 2) {
54+
C(v: i) = C(42);
55+
}
56+
i; // Not definitely unassigned
57+
} catch (_) {}
58+
}
59+
60+
main() {
61+
test1();
62+
test2();
63+
test3();
64+
test4();
65+
}

TypeSystem/flow-analysis/reachability_while_A02_t02.dart

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
/// detects assignment in `S`.
1313
/// @author [email protected]
1414
15-
main() {
15+
class C {
16+
int v;
17+
C(this.v);
18+
}
19+
20+
test1() {
1621
try {
1722
late int i;
1823
while (1 > 2) {
@@ -23,3 +28,46 @@ main() {
2328
i; // Not definitely unassigned
2429
} catch (_) {}
2530
}
31+
32+
test2() {
33+
try {
34+
late int i;
35+
while (1 > 2) {
36+
() {
37+
(i,) = (42,);
38+
};
39+
}
40+
i; // Not definitely unassigned
41+
} catch (_) {}
42+
}
43+
44+
test3() {
45+
try {
46+
late int i;
47+
while (1 > 2) {
48+
() {
49+
(x: i) = (x: 42);
50+
};
51+
}
52+
i; // Not definitely unassigned
53+
} catch (_) {}
54+
}
55+
56+
test4() {
57+
try {
58+
late int i;
59+
while (1 > 2) {
60+
() {
61+
C(v: i) = C(42);
62+
};
63+
}
64+
i; // Not definitely unassigned
65+
} catch (_) {}
66+
}
67+
68+
main() {
69+
test1();
70+
test2();
71+
test3();
72+
test4();
73+
}

0 commit comments

Comments
 (0)