[ruby-core:126539] [Ruby Bug#22278] `Coverage.line_stub` emits warnings found in source code
Issue #22278 has been reported by Earlopain (Earlopain _). ---------------------------------------- Bug #22278: `Coverage.line_stub` emits warnings found in source code https://bugs.ruby-lang.org/issues/22278 * Author: Earlopain (Earlopain _) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- `Coverage.line_stub` is implemented via `RubyVM::InstructionSequence.compile_file`. That emits all warnings found in the source code when `$VERBOSE = true`. I found this via `simplecov`. It can do coverage for compiled erb, and it also shows files that have never been used in tests via the aforementioned method. When that file is erb on disk, then trying to interpret it as ruby gives a plethora of warnings. Probably simplecov should not do that with erb in the first place, but that's another story. I started seeing this from 4.0.3 -> 4.0.4 so I guess it was because of https://bugs.ruby-lang.org/issues/22018 Here is a simple reproducer: ```rb require "coverage" require "tempfile" $VERBOSE = true Tempfile.open do |f| f.write(<<~RUBY) def foo x = 1 true end RUBY f.close Coverage.line_stub(f.path) end # $ ruby test.rb # /tmp/20260828-2866859-62r0kn:2: warning: assigned but unused variable - x ``` -- https://bugs.ruby-lang.org/
participants (1)
-
Earlopain (Earlopain _)