Python: Add data-flow tests

Alas, all these demonstrate is that we already don't fully support the
desugared `yield from` form.
This commit is contained in:
Taus
2026-04-17 12:15:04 +00:00
parent 6c675fcede
commit dc36609743

View File

@@ -257,6 +257,32 @@ def test_yield_from():
SINK(next(g)) # $ MISSING:flow="SOURCE, l:-1 -> next()"
# PEP 798: Unpacking in comprehensions.
# These desugar to `yield from`, so flow depends on yield-from support (see above).
def test_star_list_comp():
l = [[SOURCE]]
flat = [*x for x in l]
SINK(flat[0]) # $ MISSING:flow="SOURCE, l:-2 -> flat[0]"
def test_star_set_comp():
l = [[SOURCE]]
flat = {*x for x in l}
SINK(flat.pop()) # $ MISSING:flow="SOURCE, l:-2 -> flat.pop()"
def test_star_genexp():
l = [[SOURCE]]
g = (*x for x in l)
SINK(next(g)) # $ MISSING:flow="SOURCE, l:-2 -> next()"
def test_star_dictcomp():
l = [{"key": SOURCE}]
merged = {**d for d in l}
SINK(merged["key"]) # $ MISSING:flow="SOURCE, l:-2 -> merged[..]"
# a statement rather than an expression, but related to generators
def test_for():
for x in gen(SOURCE):