Issue #12438 has been reported by Vit Ondruch.

----------------------------------------
Bug #12438: OptParse: Short style switch with range does not work
https://bugs.ruby-lang.org/issues/12438

* Author: Vit Ondruch
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
This does not seems to be working:

```
$ irb
irb(main):001:0> require 'optparse'
irb(main):002:0> o = OptionParser.new
irb(main):003:0> o.on('-[a-z]') {}
irb(main):004:0> o.parse('-f')
NoMethodError: undefined method `size' for nil:NilClass
	from /usr/share/ruby/optparse.rb:433:in `block in complete'
	from /usr/share/ruby/optparse.rb:433:in `each'
	from /usr/share/ruby/optparse.rb:433:in `sort_by'
	from /usr/share/ruby/optparse.rb:433:in `complete'
	from /usr/share/ruby/optparse.rb:838:in `complete'
	from /usr/share/ruby/optparse.rb:1694:in `block in visit'
	from /usr/share/ruby/optparse.rb:1693:in `reverse_each'
	from /usr/share/ruby/optparse.rb:1693:in `visit'
	from /usr/share/ruby/optparse.rb:1725:in `block in complete'
	from /usr/share/ruby/optparse.rb:1724:in `catch'
	from /usr/share/ruby/optparse.rb:1724:in `complete'
	from /usr/share/ruby/optparse.rb:1553:in `block in parse_in_order'
	from /usr/share/ruby/optparse.rb:1527:in `catch'
	from /usr/share/ruby/optparse.rb:1527:in `parse_in_order'
	from /usr/share/ruby/optparse.rb:1521:in `order!'
	from /usr/share/ruby/optparse.rb:1613:in `permute!'
	from /usr/share/ruby/optparse.rb:1635:in `parse!'
	from /usr/share/ruby/optparse.rb:1624:in `parse'
	from (irb):4
	from /usr/bin/irb:11:in `<main>'
```

Although it is not clear from the documentation, I'd expect that this should match every short option, but unfortunately, it does not work at all ...



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>