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,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 3F1321F8C6 for ; Sun, 8 Aug 2021 14:30:38 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 6054E120A41; Sun, 8 Aug 2021 23:29:19 +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 F3EAB120971 for ; Sun, 8 Aug 2021 23:29:16 +0900 (JST) Received: by filterdrecv-7c9f9f88f-hdfbq with SMTP id filterdrecv-7c9f9f88f-hdfbq-1-610FEA87-B5 2021-08-08 14:30:31.983795021 +0000 UTC m=+1109438.130796341 Received: from herokuapp.com (unknown) by geopod-ismtpd-2-0 (SG) with ESMTP id 7u7PWvcOT62b6J-gSmJjYQ for ; Sun, 08 Aug 2021 14:30:31.904 +0000 (UTC) Date: Sun, 08 Aug 2021 14:30:32 +0000 (UTC) From: info@ttanimichi.com 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: Bug X-Redmine-Issue-Id: 18069 X-Redmine-Issue-Author: ttanimichi X-Redmine-Sender: ttanimichi 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: 80970 X-SG-EID: =?us-ascii?Q?GULVqlHThXsypk0LrcL3iR0SSuviswI2AfP7Si5YEnlVSDVOkY98uqPPx6gKzf?= =?us-ascii?Q?jFlvfvp5iV1qlcp0Ono0tDybGtmK0IcNNxQhnV=2F?= =?us-ascii?Q?VrMsC2XBhVRPjKw0WWYImy1MGn=2F0qO13Ps4IcOY?= =?us-ascii?Q?8faNYWpi5z23psOpRjF7zIsXh7Qhp4gl6qIDw7L?= =?us-ascii?Q?NjQ37NAENw4kEJ6ZxTUDXz=2FRyZ9namW207g=3D=3D?= To: ruby-dev@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-dev X-Mail-Count: 51089 Subject: [ruby-dev:51089] [Ruby master Bug#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 reported by ttanimichi (Tsukuru Tanimichi). ---------------------------------------- Bug #18069: `instance_exec` is just ignored when the block is originally a method https://bugs.ruby-lang.org/issues/18069 * Author: ttanimichi (Tsukuru Tanimichi) * Status: Open * Priority: Normal * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- 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/