From: nospam-rubylang.org@... Date: 2017-07-06T10:48:22+00:00 Subject: [ruby-core:81930] [Ruby trunk Bug#13722] OptionParser::DecimalInteger can be converted as Octal Issue #13722 has been updated by mjtko (Mark Titorenko). 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. ---------------------------------------- Bug #13722: OptionParser::DecimalInteger can be converted as Octal https://bugs.ruby-lang.org/issues/13722#change-65654 * 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: