ruby / tk

Tk interface module using tcltklib
Other
118 stars 22 forks source link

autoload.rb:455: warning: deprecated Object#=~ is called on Class; it always returns nil #22

Closed mtasaka closed 4 years ago

mtasaka commented 4 years ago

With ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux] , released ruby-tk 0.3.0 emits warnings when

Then wanings appear on cosole:

[tasaka1@localhost demos-en]$ ruby ./widget
/usr/share/gems/gems/tk-0.3.0/lib/tk/autoload.rb:455: warning: deprecated Object#=~ is called on Class; it always returns nil
/usr/share/gems/gems/tk-0.3.0/lib/tk/autoload.rb:455: warning: deprecated Object#=~ is called on Class; it always returns nil
/usr/share/gems/gems/tk-0.3.0/lib/tk/autoload.rb:455: warning: deprecated Object#=~ is called on Class; it always returns nil
/usr/share/gems/gems/tk-0.3.0/lib/tk/autoload.rb:455: warning: deprecated Object#=~ is called on Class; it always returns nil
jeremyevans commented 4 years ago

These warnings will not be displayed by default in Ruby 2.7.2. If you enable verbose warnings, then tk will emit a bunch of warnings, as it is not verbose warning free. However, it should be simple to fix this case.

rubyFeedback commented 3 years ago

If you enable verbose warnings, then tk will emit a bunch of warnings, as it is not verbose warning free. However, it should be simple to fix this case.

Thing is I have adopted a habit of using verbose -w all the time. I just like it when ruby does not warn me. :)

The tk gem could need an overhaul; there are tons of things such as

gems/tk-0.3.0/lib/tk.rb:3655: warning: instance variable @mode not initialized
gems/tk-0.3.0/lib/tk.rb:2855: warning: instance variable @encoding not initialized

I mean, these are all just warnings so they can be ignored or people can toggle-re-instate $VERBOSE, which I use anyway - but if possible, some heroic hacker could try to fix these all. I had a look at the code but the code is quite scary; it seems to be fairly old ruby code. Though I also learned something new, the initialize alias trick.

jeremyevans commented 3 years ago

Can you try #24 and see if it fixes the warnings for you?