
Issue #21123 has been updated by byroot (Jean Boussier). Status changed from Open to Rejected I agree with @mame this isn't a bug, and by design. And I don't see how it could reasonably be changed without breaking lots of code. ---------------------------------------- Bug #21123: instance_exec with curried proc https://bugs.ruby-lang.org/issues/21123#change-111805 * Author: taichi730 (Taichi Ishitani) * Status: Rejected * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- I have a question about behavior of `#instance_exec` with a curried proc. When running `#instance_exex` with a curried proc, it appears that the given proc is executed on the context where it is created but not the receiver object. Example code: ```ruby a = Object.new def a.foo(n) p end b = proc { |n| foo(n) }.curry a.instance_exec(0, &b) ``` Execution result: ``` $ ruby test.rb test.rb:6:in 'block in <main>': undefined method 'foo' for main (NoMethodError) b = proc { |n| foo(n) }.curry ^^^ Did you mean? for from test.rb:7:in 'BasicObject#instance_exec' from test.rb:7:in '<main>' ``` Is this intentional behavior? I expect that the given curried proc is also executed on the context of the receiver object like a non-curried proc. -- https://bugs.ruby-lang.org/