From: aaron.kromer+rblang@... Date: 2014-06-14T00:02:11+00:00 Subject: [ruby-core:63156] [ruby-trunk - Bug #9943] [Open] Ruby 1.9.3 improperly reports unused variable warnings Issue #9943 has been reported by Aaron Kromer. ---------------------------------------- Bug #9943: Ruby 1.9.3 improperly reports unused variable warnings https://bugs.ruby-lang.org/issues/9943 * Author: Aaron Kromer * Status: Open * Priority: Normal * Assignee: * Category: core * Target version: * ruby -v: ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.2.0] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- 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-------------------------------- another_file.rb (131 Bytes) base_script.rb (98 Bytes) -- https://bugs.ruby-lang.org/