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

Support right hand assignment #89

Merged
merged 1 commit into from Aug 3, 2020

Conversation

koic
Copy link
Member

@koic koic commented Aug 3, 2020

This PR supports right hand assignment for Ruby 2.8.0-dev (Ruby 3.0).
whitequark/parser#682

mrasgn vs masgn

mrasgn has the same structure as masgn except that the child nodes are reversed. So this PR adds mrasgn to the same constant as masgn.

mrasign

% ruby-parse -e '13.divmod(5) => a, b'
warning: parser/current is loading parser/ruby28, which recognizes
warning: 2.8.0-dev-compliant syntax, but you are running 2.8.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
(mrasgn
  (send
    (int 13) :divmod
    (int 5))
  (mlhs
    (lvasgn :a)
    (lvasgn :b)))

masign

% ruby-parse -e 'a, b = 13.divmod(5)'
warning: parser/current is loading parser/ruby28, which recognizes
warning: 2.8.0-dev-compliant syntax, but you are running 2.8.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
(masgn
  (mlhs
    (lvasgn :a)
    (lvasgn :b))
  (send
    (int 13) :divmod
    (int 5)))

rasgn

rasgn has the same structure as mrasgn without mlhs.

% ruby-parse -e '13.divmod(5) => a'
warning: parser/current is loading parser/ruby28, which recognizes
warning: 2.8.0-dev-compliant syntax, but you are running 2.8.0.
warning: please see
https://github.com/whitequark/parser#compatibility-with-ruby-mri.
(rasgn
  (send
    (int 13) :divmod
    (int 5))
  (lvasgn :a))

So this PR adds rasgn to the same constant as mrasgn.

This PR supports right hand assignment for Ruby 2.8.0-dev (Ruby 3.0).
whitequark/parser#682

## `mrasgn` vs `masgn`

`mrasgn` has the same structure as `masgn` except that the child nodes
are reversed. So this PR adds `mrasgn` to the same constant as `masgn`.

### `mrasign`

```console
% ruby-parse -e '13.divmod(5) => a, b'
warning: parser/current is loading parser/ruby28, which recognizes
warning: 2.8.0-dev-compliant syntax, but you are running 2.8.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
(mrasgn
  (send
    (int 13) :divmod
    (int 5))
  (mlhs
    (lvasgn :a)
    (lvasgn :b)))
```

### `masign`

```console
% ruby-parse -e 'a, b = 13.divmod(5)'
warning: parser/current is loading parser/ruby28, which recognizes
warning: 2.8.0-dev-compliant syntax, but you are running 2.8.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
(masgn
  (mlhs
    (lvasgn :a)
    (lvasgn :b))
  (send
    (int 13) :divmod
    (int 5)))
```

## `rasgn`

`rasgn` has the same structure as `mrasgn` without `mlhs`.
So this PR adds `rasgn` to the same constant as `mrasgn`.

```console
% ruby-parse -e '13.divmod(5) => a'
warning: parser/current is loading parser/ruby28, which recognizes
warning: 2.8.0-dev-compliant syntax, but you are running 2.8.0.
warning: please see
https://github.com/whitequark/parser#compatibility-with-ruby-mri.
(rasgn
  (send
    (int 13) :divmod
    (int 5))
  (lvasgn :a))
```
@marcandre marcandre merged commit dd1d0f4 into rubocop:master Aug 3, 2020
@marcandre
Copy link
Contributor

Looks good, thanks!

@koic koic deleted the support_right_hand_assignment branch August 3, 2020 14:14
koic added a commit to koic/rubocop-ast that referenced this pull request Aug 4, 2020
I wrote rubocop#89's changelog entry in the released section by mistake.
Also an expression of the changelog entry has been tweaked.
koic added a commit to koic/rubocop-ast that referenced this pull request Aug 4, 2020
I wrote rubocop#89's changelog entry in the released section by mistake.
This PR tweaks the changelog entry.
@koic koic mentioned this pull request Aug 4, 2020
bbatsov pushed a commit that referenced this pull request Aug 4, 2020
I wrote #89's changelog entry in the released section by mistake.
This PR tweaks the changelog entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants