Improved unpacking and iteration.

Authored by flherne on Nov 13 2016, 3:11 PM.

Description

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

Details

Committed
flherneNov 13 2016, 3:46 PM
Differential Revision
D3352: Better unpacking and iteration
Parents
R53:effa8f0f91ee: Merge branch '5.0'
Branches
Unknown
Tags
Unknown