From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 5AE141F461 for ; Sun, 7 Jul 2019 20:57:31 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A900012096B; Mon, 8 Jul 2019 05:57:22 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id EA941120956 for ; Mon, 8 Jul 2019 05:57:20 +0900 (JST) Received: by filter0014p3iad2.sendgrid.net with SMTP id filter0014p3iad2-13026-5D225CB2-C 2019-07-07 20:57:22.267450717 +0000 UTC m=+351963.175894231 Received: from herokuapp.com (unknown [35.175.150.18]) by ismtpd0002p1iad2.sendgrid.net (SG) with ESMTP id cQfmdPcMQxG1aByRcvnoYg for ; Sun, 07 Jul 2019 20:57:22.210 +0000 (UTC) Date: Sun, 07 Jul 2019 20:57:22 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 69087 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 10928 X-Redmine-Issue-Author: gettalong X-Redmine-Issue-Assignee: nobu X-Redmine-Sender: jeremyevans0 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIYunYuetMS7cO2PpYY8CFVgU=2FdguaFqF7W1y6n?= =?us-ascii?Q?b64oZ6GfmW2ekcKklD+BqudYF+DIpkCjd4fcfhU?= =?us-ascii?Q?DvM1RBaTh=2FZV0XVuQ496qzDuBkwYImkOUbHWfyz?= =?us-ascii?Q?vvZVxbvEbfI5sVPIjiBb8pvMFsEoi4hzFVg=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 93593 Subject: [ruby-core:93593] [Ruby master Bug#10928] optparse Switch#summarize code doesn't reflect its documentation X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "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/