python: Add reverse flow in some patterns

Particularly in value and literal patterns.
This is getting a little bit into the guards aspect of matching.
We could similarly add reverse flow in terms of
sub-patterns storing to a sequence pattern,
a flow step from alternatives to an-or-pattern, etc..
It does not seem too likely that sources are embedded in patterns
to begin with, but for secrets perhaps?

It is illustrated by the literal test. The value test still fails.
I believe we miss flow in general from the static attribute.
This commit is contained in:
Rasmus Lerchedahl Petersen
2022-01-27 15:20:23 +01:00
parent cb52ab669e
commit b93c04bb79
2 changed files with 41 additions and 9 deletions

View File

@@ -46,6 +46,10 @@ def test_or_pattern():
SINK(x) #$ flow="SOURCE, l:-3 -> x"
# No flow for literal pattern
def test_literal_pattern():
match SOURCE:
case 42 as x:
SINK(x) #$ flow="SOURCE, l:-2 -> x" flow="42, l:-1 -> x"
def test_capture_pattern():
match SOURCE: