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

[ruby-2.7.0] warning: The last argument is used as the keyword parameter #500

Closed
alchimere opened this issue Nov 26, 2019 · 3 comments
Closed

Comments

@alchimere
Copy link
Contributor

What I tried to do

I tested one of my ruby project against ruby-2.7.0-preview3

What I expected to happen

To work without warnings

What actually happened

Warning because of ruby 2.7 keyword argument deprecations before ruby 3.0

Versions of i18n, rails, and anything else you think is necessary

I18n 1.7.0 (standalone)


In a standard irb console with ruby-2.7.0-preview3

2.7.0-preview3 :003 > I18n.translate('translate.key', { placeholder: 'value' })
(irb):3: warning: The last argument is used as the keyword parameter
/home/yberthou/.rvm/gems/ruby-2.7.0-preview3/gems/i18n-1.7.0/lib/i18n.rb:179: warning: for `translate' defined here
@radar
Copy link
Collaborator

radar commented Nov 27, 2019

Thank you for reporting this. Would you please be able to submit a PR that fixes this issue?

@alchimere
Copy link
Contributor Author

@radar Yes I will soon

@alchimere
Copy link
Contributor Author

alchimere commented Nov 27, 2019

I just realized nothing can be done in the method itself to "fix" this, so I added a comment that explain that.

So other developers will understand faster than me.

radar added a commit that referenced this issue Jan 7, 2020
…ranslate-kwargs

Add comment on kwargs to avoid new people open issues like #500
kamipo added a commit to kamipo/i18n that referenced this issue Jan 1, 2021
Related ruby-i18n#501, ruby-i18n#500, and ruby-i18n#471.

In Ruby 3.0, the behavior of `I18n.t("key", { value: "foo" })` has
silently changed to `{ value: "foo" }` is no longer regarded as
`**options` but regarded as noop slpat arguments `*`.

https://github.com/ruby-i18n/i18n/blob/4709391dceab9096d5988576f93935843023a6ef/lib/i18n.rb#L195

So allowing (discarding) noop arguments will be more harmful in Ruby 3.0.

This removes the allowing noop arguments, it makes `{ value: "foo" }`
will raise ArgumentError instead of silently ignored the options.
radar pushed a commit that referenced this issue Jan 1, 2021
Related #501, #500, and #471.

In Ruby 3.0, the behavior of `I18n.t("key", { value: "foo" })` has
silently changed to `{ value: "foo" }` is no longer regarded as
`**options` but regarded as noop slpat arguments `*`.

https://github.com/ruby-i18n/i18n/blob/4709391dceab9096d5988576f93935843023a6ef/lib/i18n.rb#L195

So allowing (discarding) noop arguments will be more harmful in Ruby 3.0.

This removes the allowing noop arguments, it makes `{ value: "foo" }`
will raise ArgumentError instead of silently ignored the options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants