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.1 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,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 3592A1F62E for ; Wed, 16 Jan 2019 10:20:43 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 43C15120EB0; Wed, 16 Jan 2019 19:20:40 +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 E5CBA120D5A for ; Wed, 16 Jan 2019 19:20:37 +0900 (JST) Received: by filter0001p3iad2.sendgrid.net with SMTP id filter0001p3iad2-839-5C3F0572-3C 2019-01-16 10:20:34.79491577 +0000 UTC m=+133303.871025765 Received: from herokuapp.com (ec2-54-144-220-135.compute-1.amazonaws.com [54.144.220.135]) by ismtpd0026p1iad2.sendgrid.net (SG) with ESMTP id PaO24GN_Rv2mVXrrtevRoQ for ; Wed, 16 Jan 2019 10:20:34.736 +0000 (UTC) Date: Wed, 16 Jan 2019 10:20:35 +0000 (UTC) From: eregontp@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66572 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15539 X-Redmine-Issue-Author: tenderlovemaking X-Redmine-Sender: Eregon 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS7Cl4ApRphNhv4sPmVJhYKzN+2+fhln7jKo+M emETNNcX3kWwqAuOF0UrDMnX8Cg9yWKEAgM95aJ0/x3iHX7uYLlRAtqrt7p9SH+ReqAX+7FQ+Aa2qv zXbKXEn3rOeycE48HSfEul+bRllLAvH8frer+MtIoOpQ3HGbR+vUJLK1Sg== X-ML-Name: ruby-core X-Mail-Count: 91122 Subject: [ruby-core:91122] [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 Eregon (Benoit Daloze). I always thought Proc.new working without an explicit block was an unintended feature in MRI, and indeed fairly magical, so I support taking a more explicit way in 2.7. ---------------------------------------- Bug #15539: Proc.new with no block shouldn't always warn https://bugs.ruby-lang.org/issues/15539#change-76354 * 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/