Project

General

Profile

Bug #14817

TracePoint#parameters for bmethod's return event should return the same value as its Method#parameters

Added by ktsj (Kazuki Tsujimoto) over 2 years ago. Updated over 1 year ago.

Status:
Assigned
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-06-03 master 63562) [x86_64-linux]
[ruby-dev:50558]

Description

define_methodしたメソッド(bmethod)のcall/returnイベント中にTracePoint#parametersを呼び出すと
以下の結果となります。

$ cat t.rb
define_method(:bm) {|a|}

p method_parameters: method(:bm).parameters

trace = TracePoint.new(:call, :return){|tp|
  mid = tp.method_id
  if mid == :bm
    p mid: mid, event: tp.event, tp_parameters: tp.parameters
  end
}
trace.enable{
  bm(0)
}

$ ruby -v t.rb
ruby 2.6.0dev (2018-06-03 master 63562) [x86_64-linux]
{:method_parameters=>[[:req, :a]]}
{:mid=>:bm, :event=>:call, :tp_parameters=>[[:req, :a]]}
{:mid=>:bm, :event=>:return, :tp_parameters=>[]}         #=> expected: {:mid=>:bm, :event=>:return, :tp_parameters=>[[:req, :a]]}

現状、callイベントに限ってその戻り値がbmethodのMethod#parametersの呼び出し結果と一致しますが
returnイベント時も同様となるべきだと思います。

Also available in: Atom PDF