mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
reduce_nodes eliminated a bare `nil` in a method's tail (value) position
down to an empty method body, so parse.y emitted no :line event and
recorded no line coverage for that line, even though it is executed:
def m
nil # <- no :line event, no coverage under parse.y
end
The Prism compiler keeps the explicit nil and correctly emits the event.
Keep the nil in reduce_nodes when it carries a newline flag (i.e. it is
on its own line) so it still produces a line event, while the implicit
nil of an empty body (no newline flag) is still dropped. This makes
parse.y match Prism for TracePoint :line events and line coverage.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>