diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-06 09:53:33 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-06 09:53:33 +0000 |
commit | 2ad7fb6dc16baee28c3840bce6d43cc6698aaa6c (patch) | |
tree | 70f49206112361f5ea0fbf5726c39f2f470e85d0 /lib | |
parent | d32763eca0817c92ee0451ee6e08576879317e22 (diff) | |
download | ruby-2ad7fb6dc16baee28c3840bce6d43cc6698aaa6c.tar.gz |
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@pocke.me>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/optparse.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb index 11b122de95..2a2098e256 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -1165,14 +1165,14 @@ XXX # Version # def version - @version || (defined?(::Version) && ::Version) + (defined?(@version) && @version) || (defined?(::Version) && ::Version) end # # Release code # def release - @release || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE) + (defined?(@release) && @release) || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE) end # |