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

Keyword arguments have to be explicitly double-splatted in Ruby 2.7+ #486

Merged
merged 1 commit into from
Sep 3, 2019
Merged

Keyword arguments have to be explicitly double-splatted in Ruby 2.7+ #486

merged 1 commit into from
Sep 3, 2019

Conversation

amatsuda
Copy link
Contributor

@amatsuda amatsuda commented Sep 2, 2019

This PR updates the code base to be Ruby 3.0 compatible.

After a very long discussion at https://bugs.ruby-lang.org/issues/14183, the Ruby core team finally decided to introduce a slight incompatibility to keyword arguments from Ruby 3.0, i.e. complete separation between keyword arguments literal and Hash literal.
With that, current Ruby master warns when a Hash object was passed in as keyword arguments

$ ruby -ve 'def f(x: nil) p x; end; hash = {x: 1}; f(hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
warning: The last argument is used as the keyword parameter
warning: for `f' defined here

To eliminate this warning, we need to prefix a "double splat" (**) to avoid ambiguity.

$ ruby -ve 'def f(x: nil) p x;end; hash = {x: 1}; f(**hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
1

This PR fixes all Ruby 2.7 warnings (this ensures that this code works with Ruby 3.0) without breaking compatibility with Ruby < 2.7.

@radar
Copy link
Collaborator

radar commented Sep 3, 2019

You’ve been busy!! Thank you for fixing this up :)

@radar radar merged commit 2942126 into ruby-i18n:master Sep 3, 2019
@amatsuda amatsuda deleted the kwargs_2.7 branch September 4, 2019 05:14
kamipo added a commit to kamipo/mysql2 that referenced this pull request Nov 21, 2019
The Ruby core team decided to introduce a slight incompatibility to
keyword arguments from Ruby 3.0, i.e. complete separation between
keyword arguments literal and Hash literal.

https://bugs.ruby-lang.org/issues/14183
ruby/ruby#2395

With that, current Ruby master warns when a Hash object was passed in as
keyword arguments:

```
$ ruby -ve 'def f(x: nil) p x; end; hash = {x: 1}; f(hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
warning: The last argument is used as the keyword parameter
warning: for `f' defined here
1
```

To eliminate this warning, we need to prefix a "double splat" (**) to
avoid ambiguity:

```
$ ruby -ve 'def f(x: nil) p x;end; hash = {x: 1}; f(**hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
1
```

See also:

* ruby-i18n/i18n#486
* https://buildkite.com/rails/rails/builds/63974#7fb9ad05-a745-4022-b634-aa3eb9042b11/6-1865

```
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:55: warning: The last argument is used as the keyword parameter
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:94: warning: The last argument is used as the keyword parameter
```
snehaso pushed a commit to fac/mysql2 that referenced this pull request Jan 21, 2020
The Ruby core team decided to introduce a slight incompatibility to
keyword arguments from Ruby 3.0, i.e. complete separation between
keyword arguments literal and Hash literal.

https://bugs.ruby-lang.org/issues/14183
ruby/ruby#2395

With that, current Ruby master warns when a Hash object was passed in as
keyword arguments:

```
$ ruby -ve 'def f(x: nil) p x; end; hash = {x: 1}; f(hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
warning: The last argument is used as the keyword parameter
warning: for `f' defined here
1
```

To eliminate this warning, we need to prefix a "double splat" (**) to
avoid ambiguity:

```
$ ruby -ve 'def f(x: nil) p x;end; hash = {x: 1}; f(**hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
1
```

See also:

* ruby-i18n/i18n#486
* https://buildkite.com/rails/rails/builds/63974#7fb9ad05-a745-4022-b634-aa3eb9042b11/6-1865

```
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:55: warning: The last argument is used as the keyword parameter
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:94: warning: The last argument is used as the keyword parameter
```
snehaso pushed a commit to fac/mysql2 that referenced this pull request Jan 21, 2020
The Ruby core team decided to introduce a slight incompatibility to
keyword arguments from Ruby 3.0, i.e. complete separation between
keyword arguments literal and Hash literal.

https://bugs.ruby-lang.org/issues/14183
ruby/ruby#2395

With that, current Ruby master warns when a Hash object was passed in as
keyword arguments:

```
$ ruby -ve 'def f(x: nil) p x; end; hash = {x: 1}; f(hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
warning: The last argument is used as the keyword parameter
warning: for `f' defined here
1
```

To eliminate this warning, we need to prefix a "double splat" (**) to
avoid ambiguity:

```
$ ruby -ve 'def f(x: nil) p x;end; hash = {x: 1}; f(**hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
1
```

See also:

* ruby-i18n/i18n#486
* https://buildkite.com/rails/rails/builds/63974#7fb9ad05-a745-4022-b634-aa3eb9042b11/6-1865

```
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:55: warning: The last argument is used as the keyword parameter
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:94: warning: The last argument is used as the keyword parameter
```
snehaso pushed a commit to fac/mysql2 that referenced this pull request Jan 22, 2020
The Ruby core team decided to introduce a slight incompatibility to
keyword arguments from Ruby 3.0, i.e. complete separation between
keyword arguments literal and Hash literal.

https://bugs.ruby-lang.org/issues/14183
ruby/ruby#2395

With that, current Ruby master warns when a Hash object was passed in as
keyword arguments:

```
$ ruby -ve 'def f(x: nil) p x; end; hash = {x: 1}; f(hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
warning: The last argument is used as the keyword parameter
warning: for `f' defined here
1
```

To eliminate this warning, we need to prefix a "double splat" (**) to
avoid ambiguity:

```
$ ruby -ve 'def f(x: nil) p x;end; hash = {x: 1}; f(**hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
1
```

See also:

* ruby-i18n/i18n#486
* https://buildkite.com/rails/rails/builds/63974#7fb9ad05-a745-4022-b634-aa3eb9042b11/6-1865

```
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:55: warning: The last argument is used as the keyword parameter
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:94: warning: The last argument is used as the keyword parameter
```
snehaso pushed a commit to fac/mysql2 that referenced this pull request Jan 22, 2020
The Ruby core team decided to introduce a slight incompatibility to
keyword arguments from Ruby 3.0, i.e. complete separation between
keyword arguments literal and Hash literal.

https://bugs.ruby-lang.org/issues/14183
ruby/ruby#2395

With that, current Ruby master warns when a Hash object was passed in as
keyword arguments:

```
$ ruby -ve 'def f(x: nil) p x; end; hash = {x: 1}; f(hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
warning: The last argument is used as the keyword parameter
warning: for `f' defined here
1
```

To eliminate this warning, we need to prefix a "double splat" (**) to
avoid ambiguity:

```
$ ruby -ve 'def f(x: nil) p x;end; hash = {x: 1}; f(**hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
1
```

See also:

* ruby-i18n/i18n#486
* https://buildkite.com/rails/rails/builds/63974#7fb9ad05-a745-4022-b634-aa3eb9042b11/6-1865

```
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:55: warning: The last argument is used as the keyword parameter
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:94: warning: The last argument is used as the keyword parameter
```
lewispb pushed a commit to basecamp/mysql2 that referenced this pull request Jan 7, 2022
The Ruby core team decided to introduce a slight incompatibility to
keyword arguments from Ruby 3.0, i.e. complete separation between
keyword arguments literal and Hash literal.

https://bugs.ruby-lang.org/issues/14183
ruby/ruby#2395

With that, current Ruby master warns when a Hash object was passed in as
keyword arguments:

```
$ ruby -ve 'def f(x: nil) p x; end; hash = {x: 1}; f(hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
warning: The last argument is used as the keyword parameter
warning: for `f' defined here
1
```

To eliminate this warning, we need to prefix a "double splat" (**) to
avoid ambiguity:

```
$ ruby -ve 'def f(x: nil) p x;end; hash = {x: 1}; f(**hash)'
ruby 2.7.0dev (2019-09-02T05:20:05Z master 83498854eb) [x86_64-darwin18]
1
```

See also:

* ruby-i18n/i18n#486
* https://buildkite.com/rails/rails/builds/63974#7fb9ad05-a745-4022-b634-aa3eb9042b11/6-1865

```
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:55: warning: The last argument is used as the keyword parameter
/usr/local/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/error.rb:94: warning: The last argument is used as the keyword parameter
```
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.

2 participants