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=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, 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 09BAA1F62E for ; Wed, 16 Jan 2019 10:12:55 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id EEFBC1212A9; Wed, 16 Jan 2019 19:12:50 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id F2EE11211B8 for ; Wed, 16 Jan 2019 19:12:47 +0900 (JST) Received: by filter0055p3iad2.sendgrid.net with SMTP id filter0055p3iad2-15154-5C3F039D-1A 2019-01-16 10:12:45.409496368 +0000 UTC m=+132931.371786197 Received: from herokuapp.com (ec2-54-144-220-135.compute-1.amazonaws.com [54.144.220.135]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id H9OYTDKoTZK515B33nnH2g for ; Wed, 16 Jan 2019 10:12:45.321 +0000 (UTC) Date: Wed, 16 Jan 2019 10:12:46 +0000 (UTC) From: ko1@atdot.net To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66571 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15539 X-Redmine-Issue-Author: tenderlovemaking X-Redmine-Sender: ko1 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS51ihhXDPVirohEBfCvGMH3Yo8gmc85huzuUv /iMz9q8x2MRzLsCWIMfCWopqzudByQa0cJQoJqMUyzDvoc/Y7wXROmPjdFVFsTBDcvKOzrQXHGcf63 7G38JMpYrWEOitcImET5HupxjeCUYzzrP/iT X-ML-Name: ruby-core X-Mail-Count: 91121 Subject: [ruby-core:91121] [Ruby trunk Bug#15539] Proc.new with no block shouldn't always warn 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 #15539 has been updated by ko1 (Koichi Sasada). Status changed from Open to Rejected > makes it no longer possible to have a default value for a positional argument that uses the block Surprisingly, we can: ``` def foo o = binding.local_variable_get(:b), &b p o.class end foo{} #=> Proc ``` (of course it is joke code. it is too implementation dependent code so we shouldn't rely on this behavior) Anyway, I close this ticket and discuss more on new ticket I'll file. Thanks, Koichi ---------------------------------------- Bug #15539: Proc.new with no block shouldn't always warn https://bugs.ruby-lang.org/issues/15539#change-76353 * Author: tenderlovemaking (Aaron Patterson) * Status: Rejected * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- Hi, r66772 introduced a warning for the following code: ``` ruby def foo bar = Proc.new bar.call end foo { p "block" } # warn foo ->() { p "block" } # no warn ``` I don't think this case of `Proc.new` should warn. To eliminate warnings, I have to rewrite as: ``` ruby def foo bar = nil if bar bar.call else yield end end ``` Rails uses this "Proc.new" trick here: * https://github.com/rails/rails/blob/a08827a90b5a9be79379019cf5b242bd7236d2e3/actionpack/lib/action_controller/metal.rb#L29 * https://github.com/rails/rails/blob/a08827a90b5a9be79379019cf5b242bd7236d2e3/actionpack/lib/action_dispatch/middleware/stack.rb#L100 * https://github.com/rails/rails/blob/a08827a90b5a9be79379019cf5b242bd7236d2e3/activerecord/lib/active_record/statement_cache.rb#L116 * https://github.com/rails/rails/blob/a08827a90b5a9be79379019cf5b242bd7236d2e3/activesupport/lib/active_support/notifications/fanout.rb#L21 I can change Rails, but I want to know why and I don't see any discussion of r66772 (the commit doesn't have a feature number). Thanks! -- https://bugs.ruby-lang.org/