Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specs for evaluation order during assignment #1015

Merged
merged 1 commit into from
Mar 5, 2023

Conversation

dushyantss
Copy link
Contributor

This PR adds specs for Bug #4443

From:

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:

foo
bar
[]= 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

a
b
foo
[]= called on the result of foo
bar
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:

foo
bar
a
b
[]= called on the result of foo
baz= called on the result of bar
[Bug #4443]

@dushyantss dushyantss marked this pull request as draft March 5, 2023 10:44
@dushyantss dushyantss force-pushed the assignment-evaluation-order-specs branch from 9cb4a05 to 139ff1b Compare March 5, 2023 10:45
@dushyantss dushyantss marked this pull request as ready for review March 5, 2023 10:55
Copy link
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@eregon eregon merged commit 2de8961 into ruby:master Mar 5, 2023
@dushyantss dushyantss deleted the assignment-evaluation-order-specs branch March 5, 2023 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants