-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You’ve been busy!! Thank you for fixing this up :) |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
To eliminate this warning, we need to prefix a "double splat" (
**
) to avoid ambiguity.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.