Skip to content

Commit 9e083ae

Browse files
lolpackmeta-codesync[bot]
authored andcommitted
Add possibly unresolved after loop test
Summary: Add 1 new test for control flow analysis: - `test_possibly_unresolved_after_loop`: variable only defined inside loop body may be unbound Reviewed By: yangdanny97 Differential Revision: D97777539 fbshipit-source-id: 92e65dd2b2291027368ea6ff78007e33d97341b1
1 parent 5beb1d8 commit 9e083ae

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

pyrefly/lib/test/flow_looping.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,3 +918,13 @@ def process(value: int | float):
918918
(v, value) = divmod(value, 7)
919919
"#,
920920
);
921+
922+
testcase!(
923+
test_possibly_unresolved_after_loop,
924+
r#"
925+
items: list[int] = []
926+
for item in items:
927+
last = item
928+
last # E: `last` may be uninitialized
929+
"#,
930+
);

0 commit comments

Comments
 (0)