Skip to content

Multiple assignment evaluation order consistency #7440

@headius

Description

@headius

Multiple assignment evaluation order has been made consistent with
single assignment evaluation order. With single assignment, Ruby
uses a left-to-right evaluation order. With this code:

foo[0] = bar

The following evaluation order is used:

  1. foo
  2. bar
  3. []= called on the result of foo

In Ruby before 3.1.0, multiple assignment did not follow this
evaluation order. With this code:

foo[0], bar.baz = a, b

Versions of Ruby before 3.1.0 would evaluate in the following
order

  1. a
  2. b
  3. foo
  4. []= called on the result of foo
  5. bar
  6. baz= called on the result of bar

Starting in Ruby 3.1.0, the evaluation order is now consistent with
single assignment, with the left-hand side being evaluated before
the right-hand side:

  1. foo
  2. bar
  3. a
  4. b
  5. []= called on the result of foo
  6. baz= called on the result of bar

[[Bug #4443]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions