[ruby-cvs:70432] nobu:r63342 (trunk): optparse: Suppress warnings

nobu at ruby-lang.org nobu at ruby-lang.org
Sun May 6 18:53:34 JST 2018


nobu	2018-05-06 18:53:33 +0900 (Sun, 06 May 2018)

  New Revision: 63342

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63342

  Log:
    optparse: Suppress warnings
    
    Ruby warns "instance variable `@version` not initialized" for optparse when it receives `--version` option.
    
    `test.rb`
    
    ```ruby
    require 'optparse'
    Version = '1'
    OptionParser.new.parse(ARGV)
    ```
    
    ```
    $ ruby -w test.rb --version
    /home/pocke/.rbenv/versions/2.5.1/lib/ruby/2.5.0/optparse.rb:1168: warning: instance variable @version not initialized
    /home/pocke/.rbenv/versions/2.5.1/lib/ruby/2.5.0/optparse.rb:1175: warning: instance variable @release not initialized
    test 1
    ```
    
    This change will suppress the warnings.
    
    [Fix GH-1871]
    
    From: Masataka Pocke Kuwabara <kuwabara at pocke.me>

  Modified files:
    trunk/lib/optparse.rb
    trunk/test/optparse/test_summary.rb


More information about the ruby-cvs mailing list