ruby-changes:47768
From: mame <ko1@a...>
Date: Thu, 14 Sep 2017 13:42:30 +0900 (JST)
Subject: [ruby-changes:47768] mame:r59886 (trunk): Fix the lineno of case statement that has no expression
mame 2017-09-14 13:42:23 +0900 (Thu, 14 Sep 2017) New Revision: 59886 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59886 Log: Fix the lineno of case statement that has no expression Modified files: trunk/parse.y trunk/test/coverage/test_coverage.rb Index: test/coverage/test_coverage.rb =================================================================== --- test/coverage/test_coverage.rb (revision 59885) +++ test/coverage/test_coverage.rb (revision 59886) @@ -270,7 +270,7 @@ class TestCoverage < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/coverage/test_coverage.rb#L270 f.puts 'foo(2)' end - assert_in_out_err(%w[-W0 -rcoverage], <<-"end;", ["{:branches=>{[:case, 0, 2]=>{[:when, 1, 4]=>2, [:when, 2, 6]=>0, [:else, 3, 2]=>1}, [:case, 4, 14]=>{[:when, 5, 11]=>2, [:when, 6, 13]=>0, [:else, 7, 14]=>1}, [:case, 8, 16]=>{[:when, 9, 18]=>2, [:when, 10, 20]=>0, [:else, 11, 22]=>1}, [:case, 12, 32]=>{[:when, 13, 27]=>2, [:when, 14, 29]=>0, [:else, 15, 31]=>1}}}"], []) + assert_in_out_err(%w[-W0 -rcoverage], <<-"end;", ["{:branches=>{[:case, 0, 2]=>{[:when, 1, 4]=>2, [:when, 2, 6]=>0, [:else, 3, 2]=>1}, [:case, 4, 9]=>{[:when, 5, 11]=>2, [:when, 6, 13]=>0, [:else, 7, 9]=>1}, [:case, 8, 16]=>{[:when, 9, 18]=>2, [:when, 10, 20]=>0, [:else, 11, 22]=>1}, [:case, 12, 25]=>{[:when, 13, 27]=>2, [:when, 14, 29]=>0, [:else, 15, 31]=>1}}}"], []) ENV["COVERAGE_EXPERIMENTAL_MODE"] = "true" Coverage.start(branches: true) tmp = Dir.pwd Index: parse.y =================================================================== --- parse.y (revision 59885) +++ parse.y (revision 59886) @@ -2687,6 +2687,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2687 { /*%%%*/ $$ = NEW_CASE(0, $3); + nd_set_line($3, $<num>1); /*% $$ = dispatch2(case, Qnil, $3); %*/ @@ -2937,6 +2938,10 @@ k_until : keyword_until https://github.com/ruby/ruby/blob/trunk/parse.y#L2938 k_case : keyword_case { token_info_push("case"); + /*%%%*/ + $<num>$ = ruby_sourceline; + /*% + %*/ } ; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/