* [ruby-dev:51088] [Ruby master Bug#18067] Composite procs with `instance_exec` aren't executed within the context of the receiver
@ 2021-08-08 13:09 info
2021-08-09 17:57 ` [ruby-dev:51090] " merch-redmine
0 siblings, 1 reply; 2+ messages in thread
From: info @ 2021-08-08 13:09 UTC (permalink / raw)
To: ruby-dev
Issue #18067 has been reported by ttanimichi (Tsukuru Tanimichi).
----------------------------------------
Bug #18067: Composite procs with `instance_exec` aren't executed within the context of the receiver
https://bugs.ruby-lang.org/issues/18067
* 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/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-dev:51090] [Ruby master Bug#18067] Composite procs with `instance_exec` aren't executed within the context of the receiver
2021-08-08 13:09 [ruby-dev:51088] [Ruby master Bug#18067] Composite procs with `instance_exec` aren't executed within the context of the receiver info
@ 2021-08-09 17:57 ` merch-redmine
0 siblings, 0 replies; 2+ messages in thread
From: merch-redmine @ 2021-08-09 17:57 UTC (permalink / raw)
To: 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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-09 17:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-08 13:09 [ruby-dev:51088] [Ruby master Bug#18067] Composite procs with `instance_exec` aren't executed within the context of the receiver info
2021-08-09 17:57 ` [ruby-dev:51090] " merch-redmine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).