Skip to content

Commit 6dd81f7

Browse files
yangdanny97facebook-github-bot
authored andcommitted
add a test case for walrus in ternary
Summary: This works already, but we could use a test Reviewed By: rchen152 Differential Revision: D75472200 fbshipit-source-id: ac543dabb1c50deea2a75d3df979cf4ff821fa4e
1 parent 060f8f9 commit 6dd81f7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pyrefly/lib/test/narrow.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,18 @@ foos: Sequence[int] = tuple(
448448
"#,
449449
);
450450

451+
testcase!(
452+
test_walrus_ternary,
453+
r#"
454+
from typing import assert_type
455+
def get_y(x: int | None) -> int | None:
456+
return x
457+
def f(x: int | None):
458+
val = y if (y := get_y(x)) else 0
459+
assert_type(val, int)
460+
"#,
461+
);
462+
451463
testcase!(
452464
test_match_enum_fallback,
453465
r#"

0 commit comments

Comments
 (0)