Skip to content

Commit da89a3b

Browse files
kinto0meta-codesync[bot]
authored andcommitted
Add tests for a trailing Never call and an annotation-only class-body definition
Summary: - What: Add `cut_off_by_trailing_call` to `test_unset_path_from_earlier_if_needs_every_branch_on_it`, and add an annotation-only definition to `test_class_body_initialization_is_independent_of_methods`. - Why: Cover two cases that the existing tests miss: a path that misses an assignment and then stops at its own trailing `NoReturn` call, and a conditional annotation-only class-body definition that a method also assigns. The earlier `bug` version of the first test is gone: master already handles the case correctly (fixed by "Propagate conditional termination through nested flow merges"), and the other cases of this diff duplicated `cut_off_earlier` and `not_cut_off`. Reviewed By: connernilsen Differential Revision: D129184208 fbshipit-source-id: b2f1e202ce72a19120844ff6f142a3783940969d
1 parent 457e761 commit da89a3b

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎pyrefly/lib/test/attributes.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ def cond() -> bool: ...
9090
class Constructor:
9191
if cond():
9292
x = 1 # E: Attribute `x` may be uninitialized
93+
y: int # E: Attribute `y` may be uninitialized
9394
9495
def __init__(self) -> None:
9596
self.x = 2
97+
self.y = 2
9698
9799
class Helper:
98100
if cond():

‎pyrefly/lib/test/flow_branching.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4811,6 +4811,17 @@ def cut_off_later(c: bool, d: bool) -> None:
48114811
stop()
48124812
print(x)
48134813
4814+
def cut_off_by_trailing_call(c: bool, d: bool) -> None:
4815+
if c:
4816+
if d:
4817+
x = 1
4818+
else:
4819+
pass
4820+
stop()
4821+
else:
4822+
x = 2
4823+
print(x)
4824+
48144825
def cut_off_earlier(c: bool, d: bool) -> None:
48154826
if c:
48164827
x = 1

0 commit comments

Comments
 (0)