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=AWL,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 367A31F8C6 for ; Mon, 9 Aug 2021 17:57:33 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D2447120A88; Tue, 10 Aug 2021 02:56:14 +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 DC3BC120A7E for ; Tue, 10 Aug 2021 02:56:12 +0900 (JST) Received: by filterdrecv-7c9f9f88f-226hk with SMTP id filterdrecv-7c9f9f88f-226hk-1-61116C88-1 2021-08-09 17:57:28.049009968 +0000 UTC m=+1208262.426479909 Received: from herokuapp.com (unknown) by geopod-ismtpd-2-1 (SG) with ESMTP id -pkgqoHBTDeSWHOgnZdpfA for ; Mon, 09 Aug 2021 17:57:27.937 +0000 (UTC) Date: Mon, 09 Aug 2021 17:57:28 +0000 (UTC) From: merch-redmine@jeremyevans.net 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: 18067 X-Redmine-Issue-Author: ttanimichi 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-Redmine-MailingListIntegration-Message-Ids: 80985 X-SG-EID: =?us-ascii?Q?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIdrv=2F5Ka4YJyg6tLk7VQ1Yx2p3oPgUMSsYrxg9?= =?us-ascii?Q?foZmqm7JDW109zsoEUt84toeGxyalOsSkQ9Lo50?= =?us-ascii?Q?InUx=2Fpgy0fHQdGIKWIaJlDj3yR7Ad1fNJXROdOZ?= =?us-ascii?Q?L5OSKixq1wOF1rVwGM12ktcwNwKUBtqwEomL9BZ?= =?us-ascii?Q?rs83kudzfSfD2YGLw=3D?= To: ruby-dev@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-dev X-Mail-Count: 51090 Subject: [ruby-dev:51090] [Ruby master Bug#18067] Composite procs with `instance_exec` aren't executed within the context of the receiver 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 #18067 has been updated by jeremyevans0 (Jeremy Evans). I think this is expected. You get the same error if you compose the proc manually, and the proc composition operators should reflect the same behavior as manual composition: ```ruby func1 = -> (x) { x + y } class A def y 10 end end A.new.instance_exec(1, &func1) # => 11 func2 = -> (x) { x * 2 } f = ->(x) { func2.(func1.(x)) } A.new.instance_exec(1, &f) # => undefined local variable or method `y' for main:Object (NameError) ``` ---------------------------------------- Bug #18067: Composite procs with `instance_exec` aren't executed within the context of the receiver https://bugs.ruby-lang.org/issues/18067#change-93197 * Author: ttanimichi (Tsukuru Tanimichi) * Status: Open * Priority: Normal * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- ```ruby func1 = -> (x) { x + y } class A def y 10 end end A.new.instance_exec(1, &func1) # => 11 func2 = -> (x) { x * 2 } f = func1 >> func2 A.new.instance_exec(1, &f) # => undefined local variable or method `y' for main:Object (NameError) ``` -- https://bugs.ruby-lang.org/