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.1 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 96F911F8C6 for ; Tue, 10 Aug 2021 05:33:27 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 594AD120AB7; Tue, 10 Aug 2021 14:32:08 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 660F2120A7B for ; Tue, 10 Aug 2021 14:32:06 +0900 (JST) Received: by filterdrecv-7c9f9f88f-krpl8 with SMTP id filterdrecv-7c9f9f88f-krpl8-1-61120FA1-A 2021-08-10 05:33:21.254830831 +0000 UTC m=+1250012.332578691 Received: from herokuapp.com (unknown) by ismtpd0165p1iad2.sendgrid.net (SG) with ESMTP id WtwdBsyBRdWodPUbDaYwAg for ; Tue, 10 Aug 2021 05:33:21.235 +0000 (UTC) Date: Tue, 10 Aug 2021 05:33:21 +0000 (UTC) From: nobu@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 18069 X-Redmine-Issue-Author: ttanimichi X-Redmine-Sender: nobu 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-Redmine-MailingListIntegration-Message-Ids: 80997 X-SG-EID: =?us-ascii?Q?q8Dly+pU2+3ektTtZVXgZtbJPXwqo7p86jCsvYTW4BzbLhw+CjqavqWQSnS9tr?= =?us-ascii?Q?QzPybxboRzjpVcNUPSoHZcUMMFPLCqFDZEFP7t2?= =?us-ascii?Q?DMiyztyYS99Qx+Qx2o4hf+bOXa8E0ULFeJ9x=2FeM?= =?us-ascii?Q?KipIcqWRxhUgt=2F5JNb9UJBBpRr+qRO+oVw+kXr7?= =?us-ascii?Q?kI76r6nK3LtZaBPllbI7W7mhEXrFSJfPS3g=3D=3D?= To: ruby-dev@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-dev X-Mail-Count: 51092 Subject: [ruby-dev:51092] [Ruby master Feature#18069] `instance_exec` is just ignored when the block is originally a method X-BeenThere: ruby-dev@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: "Ruby developers \(Japanese\)" List-Id: "Ruby developers \(Japanese\)" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-dev-bounces@ruby-lang.org Sender: "ruby-dev" Issue #18069 has been updated by nobu (Nobuyoshi Nakada). A method is bound to the internal states of the receiver. I don't think that removing the receiver from a method makes sense. ---------------------------------------- Feature #18069: `instance_exec` is just ignored when the block is originally a method https://bugs.ruby-lang.org/issues/18069#change-93211 * Author: ttanimichi (Tsukuru Tanimichi) * Status: Open * Priority: Normal ---------------------------------------- I know you can't `instance_exec` a proc which is generated by `Method#to_proc` because it has its original instance's context. But, in such a case, raising `ArgumentError` would be the ideal behavior. ```ruby f = -> (x) { a + x } class A def a 1 end end A.new.instance_exec(1, &f) # => 2 class B def b(x) a + x end end proc = B.new.method(:b).to_proc A.new.instance_exec(1, &proc) # => undefined local variable or method `a' for # (NameError) ``` -- https://bugs.ruby-lang.org/