diff options
| author | U.Nakamura <usa@ruby-lang.org> | 2023-11-06 20:14:41 +0900 |
|---|---|---|
| committer | U.Nakamura <usa@ruby-lang.org> | 2023-11-06 20:14:41 +0900 |
| commit | d494cf4ddababb80660381e963f910ccacc3f7bc (patch) | |
| tree | 04cccc18a60c51b7a9ea13c1c657f0364e5c3759 /test | |
| parent | 18b7c768fe8500026c92c09bc922cff16989eed2 (diff) | |
merge revision(s) 4a7d6c2852aa734506be83c932168e8f974687b5: [Backport #18991]
Fix false LocalJumpError when branch coverage is enabled
`throw TAG_BREAK` instruction makes a jump only if the continuation of
catch of TAG_BREAK exactly matches the instruction immediately following
the "send" instruction that is currently being executed. Otherwise, it
seems to determine break from proc-closure.
Branch coverage may insert some recording instructions after "send"
instruction, which broke the conditions for TAG_BREAK to work properly.
This change forces to set the continuation of catch of TAG_BREAK
immediately after "send" (or "invokesuper") instruction.
[Bug #18991]
---
compile.c | 25 ++++++++++++++++++++++++-
test/coverage/test_coverage.rb | 14 ++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
Diffstat (limited to 'test')
| -rw-r--r-- | test/coverage/test_coverage.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb index 882368363a..789c2c6e90 100644 --- a/test/coverage/test_coverage.rb +++ b/test/coverage/test_coverage.rb @@ -920,4 +920,18 @@ class TestCoverage < Test::Unit::TestCase p :NG end; end + + def test_tag_break_with_branch_coverage + result = { + :branches => { + [:"&.", 0, 1, 0, 1, 6] => { + [:then, 1, 1, 0, 1, 6] => 1, + [:else, 2, 1, 0, 1, 6] => 0, + }, + }, + } + assert_coverage(<<~"end;", { branches: true }, result) + 1&.tap do break end + end; + end end |
