Issue #15634 has been updated by jeremyevans0 (Jeremy Evans).


ioquatix (Samuel Williams) wrote in #note-5:
> I wouldn't say this bug is fixed. Adding documentation just clarifies the current behaviour but does not help resolve or improve on the original problem.

Well, it depends on whether you think the current behavior is a code bug or documentation bug.  I don't think it is a code bug, because the code was not designed to give the behavior you want.  Maybe that is a design flaw, but it's not a bug in the implementation.  I agree with you that there is room for improvement in this area, but I think proposed improvements would be feature requests.

> I would say, the line tracepoint is confusing at best, as one might expect it to trigger for each "line" of executable code. The implementation obviously skips some cases, but documenting the cases that it skips does not help me much to improve the coverage computation.

I agree that `:line` as a name is not completely accurate.  With the example I gave in #note-2: 

```ruby
[
  1,
  2,
  3
]
``` 

You could reasonably assume either 3 or 5 `:line` events instead of the current 1.

Another issue I noticed with the `:line` coverage is the above example has the `:line` event as the first line, but if the array contains a non-literal, the `:line` event is on the second line.

> Maybe the problem is the naming of the tracepoint - maybe it should be called "statement" or "top_level_expression".

The issue with either of those names is that it could be trigger multiple times on the same line, so it wouldn't be a replacement for the current `:line` event.  I could see where they would be useful as additional events, though.

----------------------------------------
Bug #15634: TracePoint seems to be skipping some methods.
https://bugs.ruby-lang.org/issues/15634#change-92608

* Author: ioquatix (Samuel Williams)
* Status: Closed
* Priority: Normal
* ruby -v: 2.6.1
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
```ruby
trace_point = TracePoint.new(:call, :return, :line, :c_call, :c_return, :b_call, :b_return) do |trace|
    puts [trace.path, trace.lineno].join(":")
end

trace_point.enable

values = {foo: 10}

def shell_escape(x)
    x
end

values.map{|key, value| [
    key.to_s.upcase,
    shell_escape(value) # TracePoint is never triggered for this line.
]}
```



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>