ruby-changes:72465
From: Nobuyoshi <ko1@a...>
Date: Fri, 8 Jul 2022 11:39:41 +0900 (JST)
Subject: [ruby-changes:72465] 4a2662ae8b (master): [Bug #18890] Suppress warnings and fix the message
https://git.ruby-lang.org/ruby.git/commit/?id=4a2662ae8b From 4a2662ae8b9f64346af82551fdd6756e7497e2f1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 8 Jul 2022 11:20:02 +0900 Subject: [Bug #18890] Suppress warnings and fix the message ``` test/ruby/test_parse.rb:1384: warning: assigned but unused variable - obj test/ruby/test_pattern_matching.rb:1162: warning: unused literal ignored test/ruby/test_pattern_matching.rb:1165: warning: unused literal ignored test/ruby/test_pattern_matching.rb:1161: warning: assigned but unused variable - a test/ruby/test_pattern_matching.rb:1164: warning: assigned but unused variable - b ``` And a newline should be significant here. --- test/ruby/test_parse.rb | 2 ++ test/ruby/test_pattern_matching.rb | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 16764a2146..4488ea620e 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1394,6 +1394,7 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L1394 1 end; assert_equal(expected, eval(code)) + assert_equal(expected, obj.arg) assert_valid_syntax(code = "#{<<~"do;"}\n#{<<~'end;'}") do; @@ -1401,6 +1402,7 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L1402 1 end; assert_equal(expected, eval(code)) + assert_equal(expected, obj.arg) end =begin diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb index b8c445c806..36731e14f9 100644 --- a/test/ruby/test_pattern_matching.rb +++ b/test/ruby/test_pattern_matching.rb @@ -1155,19 +1155,26 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L1155 end end - [{a: 42}, {b: 42}].each do |i| - assert_block('newline should be insignificant after pattern label') do + bug18890 = assert_warning(/(?:.*:[47]: warning: unused literal ignored\n){2}/) do + eval("#{<<~';;;'}") + proc do |i| case i in a: - 0 - true + 0 # line 4 + a in "b": - 0 - true + 0 # line 7 + b else false end end + ;;; + end + [{a: 42}, {b: 42}].each do |i| + assert_block('newline should be significant after pattern label') do + bug18890.call(i) + end end assert_syntax_error(%q{ -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/