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

Suppress deprecated warning by Object#=~ since ruby 2.6 #129

Merged
merged 1 commit into from Jan 20, 2020

Conversation

unasuke
Copy link
Contributor

@unasuke unasuke commented Jan 9, 2020

In Temple::Mixins::GrammerDSL::Value#Rule, call =~ method to Class class then that causes a warning message.
This behavior introduced from ruby 2.6 with -W option.
(And ruby 2.7 always show a warning message)

https://bugs.ruby-lang.org/issues/15231
ruby/ruby@ebff9dc10

Therefore if "elem" is Class class, skip calling =~ method.
Therefore use case-when-else clause to avoid warning.

@judofyr
Copy link
Owner

judofyr commented Jan 16, 2020

I'm not well-versed in this code to be honest. Does this variant work as well?

case elem
when Class
  
when /…/
  
end

That would read better to me.

In `Temple::Mixins::GrammerDSL::Value#Rule`, call `=~` method to
`Class` class then that causes a warning message.
This behavior introduced from ruby 2.6 with `-W` option.
(And ruby 2.7 always show a warning message)

- https://bugs.ruby-lang.org/issues/15231
- ruby/ruby@ebff9dc10

Therefore use case-when-else clause to avoid warning.
@unasuke unasuke force-pushed the deprecate_warning_on_ruby_2_7 branch from 79f41cd to 693641f Compare January 17, 2020 18:07
@unasuke
Copy link
Contributor Author

unasuke commented Jan 17, 2020

@judofyr It seems better than my patch. Thanks!
If use case-when clause, it doesn't call =~ method, use === method internally.
So when Class clause is unneeded I thought.

@judofyr judofyr merged commit 9bfc890 into judofyr:master Jan 20, 2020
@unasuke unasuke deleted the deprecate_warning_on_ruby_2_7 branch January 22, 2020 13:22
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