diff options
author | Koichi Sasada <[email protected]> | 2023-08-01 16:51:36 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2023-08-01 18:06:25 +0900 |
commit | 6a5c548218035bfdaf226c7ab1d0af37c9480900 (patch) | |
tree | cc6a029c549a82f4d4041145a0290236981a3932 | |
parent | 0622c78869b0e9381bd709e2330b7e24feb1fb46 (diff) |
remove strange line event
```ruby
def helper_cant_rescue
begin
raise SyntaxError
rescue
cant_rescue # here
end
end
```
on this case, a line event is reported on `cant_rescue` line
because of node structure. it should not be reported.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8149
-rw-r--r-- | parse.y | 1 | ||||
-rw-r--r-- | test/ruby/test_settracefunc.rb | 24 |
2 files changed, 25 insertions, 0 deletions
@@ -12360,6 +12360,7 @@ reduce_nodes(struct parser_params *p, NODE **body) if (!subnodes(nd_head, nd_resq)) goto end; break; case NODE_RESCUE: + newline = 0; // RESBODY should not be a NEWLINE if (node->nd_else) { body = &node->nd_resq; break; diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index a30c4309ad..c5e0f328e2 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -2725,4 +2725,28 @@ CODE Foo.foo RUBY end + + def helper_cant_rescue + begin + raise SyntaxError + rescue + cant_rescue + end + end + + def test_tp_rescue + lines = [] + TracePoint.new(:line){|tp| + next unless target_thread? + lines << tp.lineno + }.enable{ + begin + helper_cant_rescue + rescue SyntaxError + end + } + call_line = lines.shift + raise_line = lines.shift + assert_equal [], lines + end end |