Skip to content

Conversation

@chiastolite
Copy link

The following massigns are not working with ruby 2.5.0 or later

a,b=1,2
a,*b=1,2
a, (b, c) = foo

This contains the fix for #21 .

```
$ docker run -it --rm rubylang/all-ruby env ALL_RUBY_SINCE=ruby-2.4 ./all-ruby -rpp -rripper -e 'pp Ripper.sexp("a,*b=1,2")'

ruby-2.4.0          [:program,
                     [[:massign,
                       [:mlhs_add_star, [[:@Ident, "a", [1, 0]]], [:@Ident, "b", [1, 3]]],
                       [:mrhs_new_from_args, [[:@int, "1", [1, 5]]], [:@int, "2", [1, 7]]]]]]
...
ruby-2.4.9          [:program,
                     [[:massign,
                       [:mlhs_add_star, [[:@Ident, "a", [1, 0]]], [:@Ident, "b", [1, 3]]],
                       [:mrhs_new_from_args, [[:@int, "1", [1, 5]]], [:@int, "2", [1, 7]]]]]]
ruby-2.5.0-preview1 [:program,
                     [[:massign,
                       [[:var_field, [:@Ident, "a", [1, 0]]],
                        [:rest_param, [:var_field, [:@Ident, "b", [1, 3]]]]],
                       [:mrhs_new_from_args, [[:@int, "1", [1, 5]]], [:@int, "2", [1, 7]]]]]]
...
ruby-2.7.0-rc2      [:program,
                     [[:massign,
                       [[:var_field, [:@Ident, "a", [1, 0]]],
                        [:rest_param, [:var_field, [:@Ident, "b", [1, 3]]]]],
                       [:mrhs_new_from_args, [[:@int, "1", [1, 5]]], [:@int, "2", [1, 7]]]]]]
```
`Patm._xs{:xs]` syntax is needed.
```
$ docker run -it --rm rubylang/all-ruby env ALL_RUBY_SINCE=ruby-2.4 ./all-ruby -rpp -rripper -e 'pp Ripper.sexp("a, (b, c) = foo")'
ruby-2.4.0          [:program,
                     [[:massign,
                       [[:@Ident, "a", [1, 0]],
                        [:mlhs_paren, [[:@Ident, "b", [1, 4]], [:@Ident, "c", [1, 7]]]]],
                       [:vcall, [:@Ident, "foo", [1, 12]]]]]]
...
ruby-2.4.9          [:program,
                     [[:massign,
                       [[:@Ident, "a", [1, 0]],
                        [:mlhs_paren, [[:@Ident, "b", [1, 4]], [:@Ident, "c", [1, 7]]]]],
                       [:vcall, [:@Ident, "foo", [1, 12]]]]]]
ruby-2.5.0-preview1 [:program,
                     [[:massign,
                       [[:var_field, [:@Ident, "a", [1, 0]]],
                        [:mlhs,
                         [:var_field, [:@Ident, "b", [1, 4]]],
                         [:var_field, [:@Ident, "c", [1, 7]]]]],
                       [:vcall, [:@Ident, "foo", [1, 12]]]]]]
...
ruby-2.7.0-rc2      [:program,
                     [[:massign,
                       [[:var_field, [:@Ident, "a", [1, 0]]],
                        [:mlhs,
                         [:var_field, [:@Ident, "b", [1, 4]]],
                         [:var_field, [:@Ident, "c", [1, 7]]]]],
                       [:vcall, [:@Ident, "foo", [1, 12]]]]]]
```
@chiastolite
Copy link
Author

chiastolite commented Jan 4, 2020

#23 is better, I think.

@chiastolite chiastolite closed this Jan 4, 2020
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.

1 participant