mirror of
https://github.com/github/codeql.git
synced 2026-05-14 19:29:28 +02:00
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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user