Actions
Bug #9943
closedRuby 1.9.3 improperly reports unused variable warnings
Bug #9943: Ruby 1.9.3 improperly reports unused variable warnings
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.2.0]
Backport:
Description
This is related to https://bugs.ruby-lang.org/issues/6693 and possibly https://bugs.ruby-lang.org/issues/7730.
Top-level unused variables prefixed with an underscore, _, do not report a warning. However, unused variables in methods or in required files which all report warnings.
The only Ruby version which incorrectly reports the warnings is 1.9.3. I've attached the simple scripts which demonstrate the issue.
$ ruby -v; ruby -w base_script.rb ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.2.0] base_script.rb:2: warning: assigned but unused variable - _a ~/another_file.rb:2: warning: assigned but unused variable - _c ~/another_file.rb:6: warning: assigned but unused variable - _d in required file end of script To confirm this was the only version, here is my output for all the versions I test:
$ rvm use 1.8.7; ruby -v; ruby -w base_script.rb Using ~/.rvm/gems/ruby-1.8.7-head ruby 1.8.7 (2014-01-28 patchlevel 376) [i686-darwin13.2.0] in required file end of script $ rvm use 1.9.2; ruby -v; ruby -w base_script.rb Using ~/.rvm/gems/ruby-1.9.2-head ruby 1.9.2p327 (2014-01-23 revision 44682) [x86_64-darwin13.2.0] in required file end of script $ rvm use 1.9.3; ruby -v; ruby -w base_script.rb Using ~/.rvm/gems/ruby-1.9.3-p547 ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.2.0] base_script.rb:2: warning: assigned but unused variable - _a ~/another_file.rb:2: warning: assigned but unused variable - _c ~/another_file.rb:6: warning: assigned but unused variable - _d in required file end of script $ rvm use 2.0.0; ruby -v; ruby -w base_script.rb Using ~/.rvm/gems/ruby-2.0.0-p481 ruby 2.0.0p481 (2014-05-08 revision 45883) [x86_64-darwin13.1.0] in required file end of script $ rvm use 2.1.2; ruby -v; ruby -w base_script.rb Using ~/.rvm/gems/ruby-2.1.2 ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0] in required file end of script Files
Updated by jeremyevans0 (Jeremy Evans) over 6 years ago
- Status changed from Open to Closed
Actions