Skip to content

Evaluation order of multiple assignment from iterable doesn't match Python #793

Open
@JukkaL

Description

@JukkaL

In code like this we should iterate over the rvalue first before performing any assignments to match Python semantics:

o.x, o.y = it

We currently interleave assignments and iteration in some cases. The evaluation order is correct if the rvalue is a list or a tuple, but not for arbitrary iterables. Assignments and iteration can have side effects, so in some edge cases these two approaches will produce different results.

Dealing with *x lvalues may make the implementation somewhat tricky (not sure though).

For more context, see python/mypy#9800 (review).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions