Project

General

Profile

Actions

Bug #18067

closed

Composite procs with `instance_exec` aren't executed within the context of the receiver

Added by ttanimichi (Tsukuru Tanimichi) over 3 years ago. Updated about 3 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-dev:51088]

Description

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)

Related issues 1 (1 open0 closed)

Has duplicate Ruby master - Feature #18815: instance_{eval,exec} vs Proc#>>OpenActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0