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=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 8C01D1F619 for ; Mon, 16 Mar 2020 16:30:10 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 09B701209A3; Tue, 17 Mar 2020 01:29:44 +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 4FC7012098B for ; Tue, 17 Mar 2020 01:29:41 +0900 (JST) Received: by filterdrecv-p3las1-7d96d95698-qg2rj with SMTP id filterdrecv-p3las1-7d96d95698-qg2rj-18-5E6FA984-30 2020-03-16 16:29:56.36246432 +0000 UTC m=+402644.357064701 Received: from herokuapp.com (unknown [34.203.204.93]) by ismtpd0020p1iad2.sendgrid.net (SG) with ESMTP id 499xan39TqOFuMZ9ZkmLrg for ; Mon, 16 Mar 2020 16:29:56.246 +0000 (UTC) Date: Mon, 16 Mar 2020 16:29:56 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 73259 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 16519 X-Redmine-Issue-Author: Eregon X-Redmine-Issue-Assignee: jeremyevans0 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?BI6OwDDfxyfg2jXKDNmG+aTyVxEHVvVaXAQvXL1?= =?us-ascii?Q?Az=2FrCgpTlzNfjfO0aXwC4OGtQvmb+N75ikrC1vj?= =?us-ascii?Q?0mPudTO9SuFaCmJliJUyMB8p6fTGzBxIsRJ7=2F+r?= =?us-ascii?Q?++bhcUi=2FgJzX+Sv6qN77iPh5x5CEquTwgcBBJTM?= =?us-ascii?Q?+=2FxIZm6BwMCmrusY0=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 97529 Subject: [ruby-core:97529] [Ruby master Bug#16519] pp [Hash.ruby2_keywords_hash({})] shows `[nil]` 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 #16519 has been updated by jeremyevans0 (Jeremy Evans). jeremyevans0 (Jeremy Evans) wrote in #note-19: > Eregon (Benoit Daloze) wrote in #note-18: > > @jeremyevans0 Could you take a look for the 2.7 backport? > > Sure, I'll take a look tomorrow and see if I can fix it locally and submit a pull request for the ruby_2_7 branch. Pull requested submitted: https://github.com/ruby/ruby/pull/2966 Things need to be handled differently in 2.7 as 2.7 will do empty keyword splat to required positional argument conversion. ---------------------------------------- Bug #16519: pp [Hash.ruby2_keywords_hash({})] shows `[nil]` https://bugs.ruby-lang.org/issues/16519#change-84690 * Author: Eregon (Benoit Daloze) * Status: Closed * Priority: Normal * Assignee: jeremyevans0 (Jeremy Evans) * ruby -v: ruby 2.8.0dev (2020-01-21T13:45:10Z master 5798d35ff6) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: REQUIRED ---------------------------------------- This happens on `master`: ``` $ ruby -ve 'ruby2_keywords def flag(*a); a.last; end; pp [flag(**{})]' ruby 2.8.0dev (2020-01-21T13:45:10Z master 5798d35ff6) [x86_64-linux] [nil] ``` Of course it should be `[{}]`, as it is for `pp [{}]`. On 2.7.0 it warns (should be fixed, it's valid to `pp` a flagged Hash): ``` $ ruby -ve 'ruby2_keywords def flag(*a); a.last; end; pp [flag(**{})]' ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] [/home/eregon/.rubies/ruby-2.7.0/lib/ruby/2.7.0/pp.rb:226: warning: Passing the keyword argument as the last hash parameter is deprecated /home/eregon/.rubies/ruby-2.7.0/lib/ruby/2.7.0/pp.rb:334: warning: The called method is defined here {}] ``` The warning being in the middle of the output is a fun fact here. Lines it refers to (still the same on current master): https://github.com/ruby/ruby/blob/v2_7_0/lib/pp.rb#L226 https://github.com/ruby/ruby/blob/v2_7_0/lib/pp.rb#L334 This is very confusing as it can happen during `test-all` and then show output such as: ``` <[{:a=>1}]> expected but was <[{:a=>1}, nil]>. ``` when the reality is (can be verified with `p` before the `assert_equal`): ``` <[{:a=>1}]> expected but was <[{:a=>1}, {}]>. ``` -- https://bugs.ruby-lang.org/