From: alxtskrnk@... Date: 2017-12-27T17:27:33+00:00 Subject: [ruby-core:84520] [Ruby trunk Bug#13774] for methods defined from procs, the binding of the resulting bound_method.to_proc does not have access to the original proc's closure environment Issue #13774 has been updated by bughit (bug hit). Subject changed from for methods defined from procs, the binding of the resulting bound method proc does not have access to the original proc's closure environment to for methods defined from procs, the binding of the resulting bound_method.to_proc does not have access to the original proc's closure environment ruby -v changed from ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] to ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux] ```ruby def foo o = Object.new local_var = 'has access to captured variable' original_proc = ->{local_var} o.define_singleton_method(:method_from_proc, &original_proc) method_proc = o.method(:method_from_proc).to_proc puts "original_proc.call #{original_proc.()}" puts "original_proc.binding #{original_proc.binding.eval('local_var')}" puts "#method_from_proc #{o.method_from_proc}" puts "method(:method_from_proc).to_proc.call #{method_proc.()}" puts "method(:method_from_proc).to_proc.binding #{method_proc.binding.eval('local_var') rescue "does not have access to captured variable: #{$!.inspect}"}" end foo ``` `method(:method_from_proc).to_proc.binding does not have access to captured variable: #{local_var} o.define_singleton_method(:lambda_method, &method_lambda) method_proc = o.method(:lambda_method).to_proc puts method_proc.() puts eval('local_var', method_lambda.binding) puts o.lambda_method puts eval('local_var', method_proc.binding) # undefined local variable or method `local_var' end foo ``` when executed as a method it has access to local_var as expected but the binding of the bound method proc does not in ruby 2.2.2 the above code crashes the vm -- https://bugs.ruby-lang.org/ Unsubscribe: