shyouhei (Shyouhei Urabe) wrote:
I wonder if this is a bug or an intended behaviour.
I would argue that this is a bug. The test here -- https://github.com/ruby/ruby/blob/trunk/test/optparse/test_acceptable.rb#L115 -- also doesn't feel correct, as it's testing that 09 generates an OptionParser::InvalidArgument exception, though that only happens because 09 is not valid octal.
If the intention is for OptionParser:DecimalInteger to behave the same as Integer but disallow hex and binary values, then perhaps it would be better called OptionParser::OctalOrDecimalInteger. :-) As there is already a specific type OptionParser::OctalInteger, it suggests to me that OptionParser::DecimalInteger should be generating base-10 output only; generating base-8 output is confusing and, for me at least, violates the principle of least surprise.