[ruby-core:66608] [ruby-trunk - Bug #10449] [TracePoint API] Duplicated line events when using parenthesis

From: ko1@...
Date: 2014-12-01 05:45:39 UTC
List: ruby-core #66608
Issue #10449 has been updated by Koichi Sasada.


> Hi Koichi, I've looked at the patch and it seems to me that _every_ duplicated event has been removed. So if I do something like
> 
>     object.method1.method2.method3
> 
> only one line event will be generated. Is this the case?

Before this fix, only 1 line event (for the method chain line) is generated, isn't?

```ruby
     1  obj = Object.new
     2  def obj.method_missing *args
     3    p args
     4    self
     5  end
     6
     7  TracePoint.new(:line){|tp|
     8    p [tp.event, tp.lineno]
     9  }.enable{
    10    obj.method1.method2.method3 # method chain line
    11  }

#=>
ruby 2.1.4p261 (2014-10-19 revision 48004) [x86_64-linux]
[:line, 10] #<-- this line
[:line, 3]
[:method1]
[:line, 4]
[:line, 3]
[:method2]
[:line, 4]
[:line, 3]
[:method3]
[:line, 4]
```


----------------------------------------
Bug #10449: [TracePoint API] Duplicated line events when using parenthesis
https://bugs.ruby-lang.org/issues/10449#change-50225

* Author: David Rodr鱈guez
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.4p265 (2014-10-27 revision 48166) [i686-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
Sometimes, when using parenthesis, I get duplicated lines events from the TracePoint API. See the failing test case, it generates 2 line events where I think it should generate just one. 

    def test_no_duplicate_line_events
      events = []
      TracePoint.new(:line) { |tp| events << tp.event }.enable { a = (1) * 5 }

      assert_equal [:line], events
    end

Thanks!!



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next