From: aladjev.andrew@... Date: 2019-12-03T21:43:22+00:00 Subject: [ruby-core:96088] [Ruby master Bug#16397] Line coverage is broken for until and while after guard clause Issue #16397 has been reported by puchuu (Andrew Aladjev). ---------------------------------------- Bug #16397: Line coverage is broken for until and while after guard clause https://bugs.ruby-lang.org/issues/16397 * Author: puchuu (Andrew Aladjev) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.6.5 * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- Hello. I was working on [ruby gem](https://github.com/andrew-aladev/ruby-zstds) and received a bug with [simplecov](https://github.com/colszowka/simplecov/issues/764). See the following [coverage report](https://codecov.io/gh/andrew-aladev/ruby-zstds/src/master/lib/zstds/stream/reader.rb#L56) for stream reader. Simplecov uses line coverage report from ruby vm. Today I've finally found a way to [extract this bug](https://gist.github.com/andrew-aladev/baa5d3ebe7718853756f75a5074e90b5) from gem source. Please use ruby 2.6.5 to run `ruby test.rb`. The result will be `[1, nil, 1, nil, 0, nil, 1]`. The right result is `[1, nil, 1, nil, 1, nil, 1]`. We can workaround this bug by adding `puts` after guard clause. Another workaround is to rewrite inline `until` using `loop do + break if`. But guard case is the key. It breaks vm or vm trace system. I will continue to investigate vm system. The suspicious thing is the method of calculating line number `use pos-1 because PC points next instruction at the beginning of instruction` but I am not sure. ---Files-------------------------------- test.rb (78 Bytes) cov.rb (67 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: