Actions
Feature #18069
open`instance_exec` is just ignored when the block is originally a method
Feature #18069:
`instance_exec` is just ignored when the block is originally a method
Status:
Open
Assignee:
-
Target version:
-
Description
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.
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 #<B:0x00007fdaf30480a0> (NameError)
Actions