ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:68378] [Ruby trunk - Bug #10928] [Open] optparse Switch#summarize code doesn't reflect its documentation
       [not found] <redmine.issue-10928.20150302172540@ruby-lang.org>
@ 2015-03-02 17:25 ` t_leitner
  2015-06-16 22:17 ` [ruby-core:69620] [Ruby trunk - Bug #10928] " antondavydov.o
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: t_leitner @ 2015-03-02 17:25 UTC (permalink / raw)
  To: ruby-core

Issue #10928 has been reported by Thomas Leitner.

----------------------------------------
Bug #10928: optparse Switch#summarize code doesn't reflect its documentation
https://bugs.ruby-lang.org/issues/10928

* Author: Thomas Leitner
* Status: Open
* Priority: Low
* Assignee: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
The documentation for `Switch#summarize` says "+sdone+::  Already summarized short style options keyed hash." for the `sdone` argument (similar problem with `ldone`). I.e. it mentions it should be a Hash.

However, the actual method definition line shows otherwise, namely an Array.

~~~
def summarize(sdone = [], ldone = [], width = 1, max = width - 1, indent = "")
~~~

The `OptionParser#summarize` command does actually invoke it with Hashes as arguments (line 566): `visit(:summarize, {}, {}, width, max, indent, &blk)`.

So the method definition for `Switch#summarize` is probably false.



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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:69620] [Ruby trunk - Bug #10928] optparse Switch#summarize code doesn't reflect its documentation
       [not found] <redmine.issue-10928.20150302172540@ruby-lang.org>
  2015-03-02 17:25 ` [ruby-core:68378] [Ruby trunk - Bug #10928] [Open] optparse Switch#summarize code doesn't reflect its documentation t_leitner
@ 2015-06-16 22:17 ` antondavydov.o
  2019-07-07 20:57 ` [ruby-core:93593] [Ruby master Bug#10928] " merch-redmine
  2019-07-08  1:46 ` [ruby-core:93604] " nobu
  3 siblings, 0 replies; 4+ messages in thread
From: antondavydov.o @ 2015-06-16 22:17 UTC (permalink / raw)
  To: ruby-core

Issue #10928 has been updated by Anton Davydov.


Hello,

> However, the actual method definition line shows otherwise, namely an Array.

In documentations says that `sdone` and `ldone` options take keyed hash. It's mean that this options take array with hash keys.

> The `OptionParser#summarize` command does actually invoke it with Hashes as arguments (line 566): `visit(:summarize, {}, {}, width, max, indent, &blk)`.

It's different methods. In first case it's `Switch#summarize` and in second case it's `OptionParser#summarize`.

----------------------------------------
Bug #10928: optparse Switch#summarize code doesn't reflect its documentation
https://bugs.ruby-lang.org/issues/10928#change-52963

* Author: Thomas Leitner
* Status: Open
* Priority: Low
* Assignee: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
The documentation for `Switch#summarize` says "+sdone+::  Already summarized short style options keyed hash." for the `sdone` argument (similar problem with `ldone`). I.e. it mentions it should be a Hash.

However, the actual method definition line shows otherwise, namely an Array.

~~~
def summarize(sdone = [], ldone = [], width = 1, max = width - 1, indent = "")
~~~

The `OptionParser#summarize` command does actually invoke it with Hashes as arguments (line 566): `visit(:summarize, {}, {}, width, max, indent, &blk)`.

So the method definition for `Switch#summarize` is probably false.



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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:93593] [Ruby master Bug#10928] optparse Switch#summarize code doesn't reflect its documentation
       [not found] <redmine.issue-10928.20150302172540@ruby-lang.org>
  2015-03-02 17:25 ` [ruby-core:68378] [Ruby trunk - Bug #10928] [Open] optparse Switch#summarize code doesn't reflect its documentation t_leitner
  2015-06-16 22:17 ` [ruby-core:69620] [Ruby trunk - Bug #10928] " antondavydov.o
@ 2019-07-07 20:57 ` merch-redmine
  2019-07-08  1:46 ` [ruby-core:93604] " nobu
  3 siblings, 0 replies; 4+ messages in thread
From: merch-redmine @ 2019-07-07 20:57 UTC (permalink / raw)
  To: ruby-core

Issue #10928 has been updated by jeremyevans0 (Jeremy Evans).

Assignee set to nobu (Nobuyoshi Nakada)
Status changed from Open to Assigned
File optparse-switch-summarize.patch added

I agree that this is a bug and it should be fixed.  You can trigger it by calling `OptionParser::Switch#summarize` without arguments:

```ruby
require 'optparse'
o = OptionParser.new
o.on('-c'){}
o.instance_variable_get(:@stack)[2].instance_variable_get(:@short).values.first.summarize{}
# TypeError (no implicit conversion of String into Integer)
```

Attached is a patch that fixes the issue.

----------------------------------------
Bug #10928: optparse Switch#summarize code doesn't reflect its documentation
https://bugs.ruby-lang.org/issues/10928#change-79185

* Author: gettalong (Thomas Leitner)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
The documentation for `Switch#summarize` says "+sdone+::  Already summarized short style options keyed hash." for the `sdone` argument (similar problem with `ldone`). I.e. it mentions it should be a Hash.

However, the actual method definition line shows otherwise, namely an Array.

~~~
def summarize(sdone = [], ldone = [], width = 1, max = width - 1, indent = "")
~~~

The `OptionParser#summarize` command does actually invoke it with Hashes as arguments (line 566): `visit(:summarize, {}, {}, width, max, indent, &blk)`.

So the method definition for `Switch#summarize` is probably false.

---Files--------------------------------
optparse-switch-summarize.patch (1.19 KB)


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:93604] [Ruby master Bug#10928] optparse Switch#summarize code doesn't reflect its documentation
       [not found] <redmine.issue-10928.20150302172540@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-07-07 20:57 ` [ruby-core:93593] [Ruby master Bug#10928] " merch-redmine
@ 2019-07-08  1:46 ` nobu
  3 siblings, 0 replies; 4+ messages in thread
From: nobu @ 2019-07-08  1:46 UTC (permalink / raw)
  To: ruby-core

Issue #10928 has been updated by nobu (Nobuyoshi Nakada).


Thank you, I've missed it.
Commit it please.

----------------------------------------
Bug #10928: optparse Switch#summarize code doesn't reflect its documentation
https://bugs.ruby-lang.org/issues/10928#change-79200

* Author: gettalong (Thomas Leitner)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
The documentation for `Switch#summarize` says "+sdone+::  Already summarized short style options keyed hash." for the `sdone` argument (similar problem with `ldone`). I.e. it mentions it should be a Hash.

However, the actual method definition line shows otherwise, namely an Array.

~~~
def summarize(sdone = [], ldone = [], width = 1, max = width - 1, indent = "")
~~~

The `OptionParser#summarize` command does actually invoke it with Hashes as arguments (line 566): `visit(:summarize, {}, {}, width, max, indent, &blk)`.

So the method definition for `Switch#summarize` is probably false.

---Files--------------------------------
optparse-switch-summarize.patch (1.19 KB)


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-08  1:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-10928.20150302172540@ruby-lang.org>
2015-03-02 17:25 ` [ruby-core:68378] [Ruby trunk - Bug #10928] [Open] optparse Switch#summarize code doesn't reflect its documentation t_leitner
2015-06-16 22:17 ` [ruby-core:69620] [Ruby trunk - Bug #10928] " antondavydov.o
2019-07-07 20:57 ` [ruby-core:93593] [Ruby master Bug#10928] " merch-redmine
2019-07-08  1:46 ` [ruby-core:93604] " nobu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).