Issue #13722 has been updated by wmccumstie (William McCumstie).


I don't believe it would be intended behaviour. At very least it would be strange to specifically specify a Decimal only to have it converted as Octal.

Looking into to the unit tests (test/optparse/test_acceptable.rb:115), I would have expected the intended behaviour to raise OptionParser::InvalidArgument if anything.

The behaviour also appears to be different if the input is an array compared to a string (["--decimal", "035"] vs "--decimal 035").

----------------------------------------
Bug #13722: OptionParser::DecimalInteger can be converted as Octal
https://bugs.ruby-lang.org/issues/13722#change-65655

* Author: wmccumstie (William McCumstie)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0dev (2017-07-03 trunk 59255) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
OptionParser::DecimalInteger will convert in octal format for input values that start with a '0'. In the attached script, an input of '035' will be converted to 29.

Script Output:
$: ./ruby-op-octal-bug.rb 
Input: 035
Parsed: 29

---Files--------------------------------
ruby-op-octal-bug.rb (332 Bytes)


-- 
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>