Skip to content
Commit 69177a77 authored by Francis Herne's avatar Francis Herne
Browse files

Improved unpacking and iteration.

Make unpacking in assignments handle unsure-types (unpack all suitable
types and combine the results).
```
a = 1, 2, 3
a = ["a", "b", "c"]
x, y, z = a  # 'unsure (int, str)' rather than 'mixed'.
```

Reimplement visitFor() and visitComprehension() to use the assignment
code, which has better unpacking support and saves a lot of lines.

For-loops and comprehensions now get a type when used on tuples:
 `for x in 1, 2, 3: pass # 'int'`
...and support nested and PEP-3132 unpacking:
```
for first, *middle, (a, b) in [(1, 2, 3, (4, 5))]:
    pass # middle: 'list of int', a: 'int'
```
BUG: 359915

Iterating over dicts now gets the key type rather than values.

Fixes one previously-XFAIL test, adds a few more. No known regressions.

Differential Revision: https://phabricator.kde.org/D3352
parent effa8f0f
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment